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