Skip to content

Commit

Permalink
Add test with boxes
Browse files Browse the repository at this point in the history
  • Loading branch information
zakarumych committed May 22, 2023
1 parent db8f3a1 commit 8056a61
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -50,3 +50,17 @@ pub fn test_vec<A: Allocator>(alloc: A) {
vec.resize(12467, 0xfe);
drop(vec);
}

pub fn test_many_boxes<A: Allocator + Copy>(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);
}

0 comments on commit 8056a61

Please sign in to comment.