1*43a90889SApple OSS Distributions //
2*43a90889SApple OSS Distributions // Tests for
3*43a90889SApple OSS Distributions // template <typename T, typename R>
4*43a90889SApple OSS Distributions // bool operator==(intrusive_shared_ptr<T, R> const& x, std::nullptr_t);
5*43a90889SApple OSS Distributions //
6*43a90889SApple OSS Distributions // template <typename T, typename R>
7*43a90889SApple OSS Distributions // bool operator!=(intrusive_shared_ptr<T, R> const& x, std::nullptr_t);
8*43a90889SApple OSS Distributions //
9*43a90889SApple OSS Distributions // template <typename T, typename R>
10*43a90889SApple OSS Distributions // bool operator==(std::nullptr_t, intrusive_shared_ptr<T, R> const& x);
11*43a90889SApple OSS Distributions //
12*43a90889SApple OSS Distributions // template <typename T, typename R>
13*43a90889SApple OSS Distributions // bool operator!=(std::nullptr_t, intrusive_shared_ptr<T, R> const& x);
14*43a90889SApple OSS Distributions //
15*43a90889SApple OSS Distributions
16*43a90889SApple OSS Distributions #include <libkern/c++/intrusive_shared_ptr.h>
17*43a90889SApple OSS Distributions #include <darwintest.h>
18*43a90889SApple OSS Distributions #include "test_policy.h"
19*43a90889SApple OSS Distributions
20*43a90889SApple OSS Distributions struct T { int i; };
21*43a90889SApple OSS Distributions
22*43a90889SApple OSS Distributions template <typename T, typename U>
23*43a90889SApple OSS Distributions static void
check_eq(T t,U u)24*43a90889SApple OSS Distributions check_eq(T t, U u)
25*43a90889SApple OSS Distributions {
26*43a90889SApple OSS Distributions CHECK(t == u);
27*43a90889SApple OSS Distributions CHECK(u == t);
28*43a90889SApple OSS Distributions CHECK(!(t != u));
29*43a90889SApple OSS Distributions CHECK(!(u != t));
30*43a90889SApple OSS Distributions }
31*43a90889SApple OSS Distributions
32*43a90889SApple OSS Distributions template <typename T, typename U>
33*43a90889SApple OSS Distributions static void
check_ne(T t,U u)34*43a90889SApple OSS Distributions check_ne(T t, U u)
35*43a90889SApple OSS Distributions {
36*43a90889SApple OSS Distributions CHECK(!(t == u));
37*43a90889SApple OSS Distributions CHECK(!(u == t));
38*43a90889SApple OSS Distributions CHECK(t != u);
39*43a90889SApple OSS Distributions CHECK(u != t);
40*43a90889SApple OSS Distributions }
41*43a90889SApple OSS Distributions
42*43a90889SApple OSS Distributions template <typename T, typename TQual>
43*43a90889SApple OSS Distributions static void
tests()44*43a90889SApple OSS Distributions tests()
45*43a90889SApple OSS Distributions {
46*43a90889SApple OSS Distributions T obj{3};
47*43a90889SApple OSS Distributions
48*43a90889SApple OSS Distributions {
49*43a90889SApple OSS Distributions test_shared_ptr<TQual> const a(&obj, libkern::no_retain);
50*43a90889SApple OSS Distributions check_ne(a, nullptr);
51*43a90889SApple OSS Distributions }
52*43a90889SApple OSS Distributions
53*43a90889SApple OSS Distributions {
54*43a90889SApple OSS Distributions test_shared_ptr<TQual> const a = nullptr;
55*43a90889SApple OSS Distributions check_eq(a, nullptr);
56*43a90889SApple OSS Distributions }
57*43a90889SApple OSS Distributions }
58*43a90889SApple OSS Distributions
59*43a90889SApple OSS Distributions T_DECL(compare_equal_nullptr, "intrusive_shared_ptr.compare.equal.nullptr", T_META_TAG_VM_PREFERRED) {
60*43a90889SApple OSS Distributions tests<T, T>();
61*43a90889SApple OSS Distributions tests<T, T const>();
62*43a90889SApple OSS Distributions }
63