// // Tests for // template // bool operator==(intrusive_shared_ptr const& x, intrusive_shared_ptr const& y); // // template // bool operator!=(intrusive_shared_ptr const& x, intrusive_shared_ptr const& y); // #include #include #include "test_policy.h" struct Base { int i; }; struct Derived : Base { }; struct T { int i; }; template static void check_eq(T t, U u) { CHECK(t == u); CHECK(u == t); CHECK(!(t != u)); CHECK(!(u != t)); } template static void check_ne(T t, U u) { CHECK(!(t == u)); CHECK(!(u == t)); CHECK(t != u); CHECK(u != t); } template static void tests() { T obj1{1}; T obj2{2}; { test_shared_ptr const a(&obj1, libkern::no_retain); test_shared_ptr const b(&obj2, libkern::no_retain); check_ne(a, b); } { test_shared_ptr const a(&obj1, libkern::no_retain); test_shared_ptr const b(&obj1, libkern::no_retain); check_eq(a, b); } { test_shared_ptr const a = nullptr; test_shared_ptr const b(&obj2, libkern::no_retain); check_ne(a, b); } { test_shared_ptr const a = nullptr; test_shared_ptr const b = nullptr; check_eq(a, b); } } template static void tests_convert() { T obj{1}; test_shared_ptr const a(&obj, libkern::no_retain); test_shared_ptr const b(&obj, libkern::no_retain); check_eq(a, b); } T_DECL(compare_equal, "intrusive_shared_ptr.compare.equal", T_META_TAG_VM_PREFERRED) { tests(); tests(); tests_convert(); tests_convert(); }