]>
git.saurik.com Git - apple/xnu.git/blob - tests/safe_allocation_src/size.cpp
3 // size_t size() const;
6 #include <libkern/c++/safe_allocation.h>
7 #include <darwintest.h>
8 #include "test_utils.h"
10 #include <type_traits>
22 test_safe_allocation
<T
> const array(10, libkern::allocate_memory
);
23 CHECK(array
.size() == 10);
26 T
* memory
= reinterpret_cast<T
*>(malloc_allocator::allocate(10 * sizeof(T
)));
27 test_safe_allocation
<T
> const array(memory
, 10, libkern::adopt_memory
);
28 CHECK(array
.size() == 10);
31 test_safe_allocation
<T
> const array(nullptr, 0, libkern::adopt_memory
);
32 CHECK(array
.size() == 0);
35 test_safe_allocation
<T
> const array
;
36 CHECK(array
.size() == 0);
40 using Size
= decltype(std::declval
<test_safe_allocation
<T
> const&>().size());
41 static_assert(std::is_same_v
<Size
, std::size_t>);
45 T_DECL(size
, "safe_allocation.size") {