]>
git.saurik.com Git - apple/xnu.git/blob - tests/safe_allocation_src/ctor.adopt.cpp
3 // explicit safe_allocation(T* data, size_t n, adopt_memory_t);
6 #include <libkern/c++/safe_allocation.h>
7 #include <darwintest.h>
8 #include "test_utils.h"
19 T
* memory
= reinterpret_cast<T
*>(tracking_allocator::allocate(10 * sizeof(T
)));
20 tracking_allocator::reset();
22 tracked_safe_allocation
<T
> array(memory
, 10, libkern::adopt_memory
);
23 CHECK(!tracking_allocator::did_allocate
);
24 CHECK(array
.data() == memory
);
25 CHECK(array
.size() == 10);
26 CHECK(array
.begin() == array
.data());
27 CHECK(array
.end() == array
.data() + 10);
29 CHECK(tracking_allocator::deallocated_size
== 10 * sizeof(T
));
33 T_DECL(ctor_adopt
, "safe_allocation.ctor.adopt") {