// // Tests for // bounded_ptr(std::nullptr_t); // #include #include #include #include "test_utils.h" #define _assert(...) T_ASSERT_TRUE((__VA_ARGS__), # __VA_ARGS__) struct T { }; template static void tests() { // Test with nullptr { test_bounded_ptr p = nullptr; _assert(p == nullptr); } { test_bounded_ptr p{nullptr}; _assert(p == nullptr); } { test_bounded_ptr p(nullptr); _assert(p == nullptr); } { test_bounded_ptr p = static_cast >(nullptr); _assert(p == nullptr); } { auto f = [](test_bounded_ptr p) { _assert(p == nullptr); }; f(nullptr); } // Test with NULL { test_bounded_ptr p = NULL; _assert(p == nullptr); } { test_bounded_ptr p{NULL}; _assert(p == nullptr); } { test_bounded_ptr p(NULL); _assert(p == nullptr); } { test_bounded_ptr p = static_cast >(NULL); _assert(p == nullptr); } { auto f = [](test_bounded_ptr p) { _assert(p == nullptr); }; f(NULL); } // Test with 0 { test_bounded_ptr p = 0; _assert(p == nullptr); } { test_bounded_ptr p{0}; _assert(p == nullptr); } { test_bounded_ptr p(0); _assert(p == nullptr); } { test_bounded_ptr p = static_cast >(0); _assert(p == nullptr); } { auto f = [](test_bounded_ptr p) { _assert(p == nullptr); }; f(0); } } T_DECL(ctor_nullptr, "bounded_ptr.ctor.nullptr", T_META_TAG_VM_PREFERRED) { tests(); tests(); tests(); tests(); }