// // Tests for // size_t size() const; // #include #include #include "test_utils.h" #include #include #include struct T { int i; }; template static void tests() { { test_safe_allocation const array(10, libkern::allocate_memory); CHECK(array.size() == 10); } { T* memory = reinterpret_cast(malloc_allocator::allocate(10 * sizeof(T))); test_safe_allocation const array(memory, 10, libkern::adopt_memory); CHECK(array.size() == 10); } { test_safe_allocation const array(nullptr, 0, libkern::adopt_memory); CHECK(array.size() == 0); } { test_safe_allocation const array; CHECK(array.size() == 0); } { using Size = decltype(std::declval const&>().size()); static_assert(std::is_same_v); } } T_DECL(size, "safe_allocation.size", T_META_TAG_VM_PREFERRED) { tests(); tests(); }