]>
git.saurik.com Git - apple/xnu.git/blob - tests/safe_allocation_src/assign.nullptr.cpp
3 // safe_allocation& operator=(std::nullptr_t);
6 #include <libkern/c++/safe_allocation.h>
7 #include <darwintest.h>
8 #include "test_utils.h"
18 // Assign to a non-null allocation
20 tracked_safe_allocation
<T
> array(10, libkern::allocate_memory
);
21 tracking_allocator::reset();
23 tracked_safe_allocation
<T
>& ref
= (array
= nullptr);
24 CHECK(&ref
== &array
);
25 CHECK(array
.data() == nullptr);
26 CHECK(array
.size() == 0);
27 CHECK(tracking_allocator::did_deallocate
);
30 // Assign to a null allocation
32 tracked_safe_allocation
<T
> array
= nullptr;
33 tracking_allocator::reset();
35 tracked_safe_allocation
<T
>& ref
= (array
= nullptr);
36 CHECK(&ref
== &array
);
37 CHECK(array
.data() == nullptr);
38 CHECK(array
.size() == 0);
39 CHECK(!tracking_allocator::did_deallocate
);
43 T_DECL(assign_nullptr
, "safe_allocation.assign.nullptr") {