// // Tests for // bounded_ptr& operator=(std::nullptr_t); // #include #include #include #include #include "test_utils.h" #define _assert(...) T_ASSERT_TRUE((__VA_ARGS__), # __VA_ARGS__) struct T { }; template static void tests() { T obj{}; // Assign from nullptr { test_bounded_ptr p(&obj, &obj, &obj + 1); _assert(p != nullptr); test_bounded_ptr& ref = (p = nullptr); _assert(&ref == &p); _assert(p == nullptr); } // Assign from NULL { test_bounded_ptr p(&obj, &obj, &obj + 1); _assert(p != nullptr); test_bounded_ptr& ref = (p = NULL); _assert(&ref == &p); _assert(p == nullptr); } // Assign from 0 { test_bounded_ptr p(&obj, &obj, &obj + 1); _assert(p != nullptr); test_bounded_ptr& ref = (p = 0); _assert(&ref == &p); _assert(p == nullptr); } } T_DECL(assign_nullptr, "bounded_ptr.assign.nullptr", T_META_TAG_VM_PREFERRED) { tests(); tests(); tests(); tests(); }