]>
git.saurik.com Git - apple/xnu.git/blob - tests/safe_allocation_src/dtor.cpp
6 #include <libkern/c++/safe_allocation.h>
7 #include <darwintest.h>
8 #include "test_utils.h"
10 struct TriviallyDestructible
{
14 struct NonTriviallyDestructible
{
16 ~NonTriviallyDestructible()
25 // Destroy a non-null allocation
28 tracked_safe_allocation
<T
> array(10, libkern::allocate_memory
);
29 tracking_allocator::reset();
31 CHECK(tracking_allocator::deallocated_size
== 10 * sizeof(T
));
34 // Destroy a null allocation
37 tracked_safe_allocation
<T
> array
= nullptr;
38 tracking_allocator::reset();
40 CHECK(!tracking_allocator::did_deallocate
);
44 T_DECL(dtor
, "safe_allocation.dtor") {
45 tests
<TriviallyDestructible
>();
46 tests
<TriviallyDestructible
const>();
48 tests
<NonTriviallyDestructible
>();
49 tests
<NonTriviallyDestructible
const>();