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