// // Tests for // explicit safe_allocation(T* data, size_t n, adopt_memory_t); // #include #include #include "test_utils.h" struct T { int i; }; template static void tests() { { T* memory = reinterpret_cast(tracking_allocator::allocate(10 * sizeof(T))); tracking_allocator::reset(); { tracked_safe_allocation array(memory, 10, libkern::adopt_memory); CHECK(!tracking_allocator::did_allocate); CHECK(array.data() == memory); CHECK(array.size() == 10); CHECK(array.begin() == array.data()); CHECK(array.end() == array.data() + 10); } CHECK(tracking_allocator::deallocated_size == 10 * sizeof(T)); } } T_DECL(ctor_adopt, "safe_allocation.ctor.adopt", T_META_TAG_VM_PREFERRED) { tests(); tests(); }