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