// // Tests for // template // bool operator==(std::nullptr_t, bounded_ptr const& p); // // template // bool operator!=(std::nullptr_t, bounded_ptr const& p); // // template // bool operator==(bounded_ptr const& p, std::nullptr_t); // // template // bool operator!=(bounded_ptr const& p, std::nullptr_t); // #include #include #include #include "test_utils.h" #define _assert(...) T_ASSERT_TRUE((__VA_ARGS__), # __VA_ARGS__) struct T { }; struct non_default_policy { static constexpr void trap(char const*) { } }; template static void tests() { T t; { test_bounded_ptr const ptr(&t, &t, &t + 1); _assert(!(ptr == nullptr)); _assert(!(nullptr == ptr)); _assert(ptr != nullptr); _assert(nullptr != ptr); } { test_bounded_ptr const ptr = nullptr; _assert(ptr == nullptr); _assert(nullptr == ptr); _assert(!(ptr != nullptr)); _assert(!(nullptr != ptr)); } // Test with a custom policy { libkern::bounded_ptr const ptr = nullptr; _assert(ptr == nullptr); _assert(nullptr == ptr); _assert(!(ptr != nullptr)); _assert(!(nullptr != ptr)); } } T_DECL(compare_equal_nullptr, "bounded_ptr.compare.equal.nullptr", T_META_TAG_VM_PREFERRED) { tests(); tests(); tests(); tests(); }