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