// // Tests for // safe_allocation& operator=(std::nullptr_t); // #include #include #include "test_utils.h" struct T { int i; }; template static void tests() { // Assign to a non-null allocation { tracked_safe_allocation array(10, libkern::allocate_memory); tracking_allocator::reset(); tracked_safe_allocation& ref = (array = nullptr); CHECK(&ref == &array); CHECK(array.data() == nullptr); CHECK(array.size() == 0); CHECK(tracking_allocator::did_deallocate); } // Assign to a null allocation { tracked_safe_allocation array = nullptr; tracking_allocator::reset(); tracked_safe_allocation& ref = (array = nullptr); CHECK(&ref == &array); CHECK(array.data() == nullptr); CHECK(array.size() == 0); CHECK(!tracking_allocator::did_deallocate); } } T_DECL(assign_nullptr, "safe_allocation.assign.nullptr", T_META_TAG_VM_PREFERRED) { tests(); tests(); }