// // Tests for // T* data(); // T const* data() const; // #include #include #include "test_utils.h" struct T { int i; }; template static void tests() { { test_safe_allocation array(10, libkern::allocate_memory); CHECK(array.data() != nullptr); } { T* memory = reinterpret_cast(malloc_allocator::allocate(10 * sizeof(T))); test_safe_allocation array(memory, 10, libkern::adopt_memory); T* data = array.data(); CHECK(data == memory); } { T* memory = reinterpret_cast(malloc_allocator::allocate(10 * sizeof(T))); test_safe_allocation const array(memory, 10, libkern::adopt_memory); T const* data = array.data(); CHECK(data == memory); } } T_DECL(data, "safe_allocation.data", T_META_TAG_VM_PREFERRED) { tests(); tests(); }