From 8056a615352281da2874be95a0510c7e099126ca Mon Sep 17 00:00:00 2001 From: Zakarum Date: Mon, 22 May 2023 12:45:09 +0300 Subject: [PATCH] Add test with boxes --- tests/src/lib.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/src/lib.rs b/tests/src/lib.rs index ba3bc7b..2db6af3 100644 --- a/tests/src/lib.rs +++ b/tests/src/lib.rs @@ -2,7 +2,7 @@ use std::alloc::Layout; -use allocator_api2::{alloc::Allocator, vec::Vec}; +use allocator_api2::{alloc::Allocator, boxed::Box, vec::Vec}; #[macro_export] macro_rules! make_test { @@ -50,3 +50,17 @@ pub fn test_vec(alloc: A) { vec.resize(12467, 0xfe); drop(vec); } + +pub fn test_many_boxes(alloc: A) { + let mut boxes = Vec::new_in(alloc); + + for i in 0..15 { + boxes.push(Box::new_in(i, alloc)); + } + + for i in 0..15 { + assert_eq!(*boxes[i], i); + } + + drop(boxes); +}