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