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