]>
git.saurik.com Git - apple/xnu.git/blob - tests/bounded_ptr_src/compare.equal.nullptr.cpp
3 // template <typename T, typename Policy>
4 // bool operator==(std::nullptr_t, bounded_ptr<T, Policy> const& p);
6 // template <typename T, typename Policy>
7 // bool operator!=(std::nullptr_t, bounded_ptr<T, Policy> const& p);
9 // template <typename T, typename Policy>
10 // bool operator==(bounded_ptr<T, Policy> const& p, std::nullptr_t);
12 // template <typename T, typename Policy>
13 // bool operator!=(bounded_ptr<T, Policy> const& p, std::nullptr_t);
16 #include <libkern/c++/bounded_ptr.h>
17 #include <darwintest.h>
18 #include <darwintest_utils.h>
19 #include "test_utils.h"
21 #define _assert(...) T_ASSERT_TRUE((__VA_ARGS__), # __VA_ARGS__)
25 struct non_default_policy
{
32 template <typename T
, typename QualT
>
39 test_bounded_ptr
<QualT
> const ptr(&t
, &t
, &t
+ 1);
40 _assert(!(ptr
== nullptr));
41 _assert(!(nullptr == ptr
));
42 _assert(ptr
!= nullptr);
43 _assert(nullptr != ptr
);
46 test_bounded_ptr
<QualT
> const ptr
= nullptr;
47 _assert(ptr
== nullptr);
48 _assert(nullptr == ptr
);
49 _assert(!(ptr
!= nullptr));
50 _assert(!(nullptr != ptr
));
53 // Test with a custom policy
55 libkern::bounded_ptr
<QualT
, non_default_policy
> const ptr
= nullptr;
56 _assert(ptr
== nullptr);
57 _assert(nullptr == ptr
);
58 _assert(!(ptr
!= nullptr));
59 _assert(!(nullptr != ptr
));
63 T_DECL(compare_equal_nullptr
, "bounded_ptr.compare.equal.nullptr") {
66 tests
<T
, T
volatile>();
67 tests
<T
, T
const volatile>();