1*e3723e1fSApple OSS Distributions //
2*e3723e1fSApple OSS Distributions // Tests for
3*e3723e1fSApple OSS Distributions // template <typename T, typename Alloc, typename TrappingPolicy>
4*e3723e1fSApple OSS Distributions // bool operator==(std::nullptr_t, safe_allocation<T, Alloc, TrappingPolicy> const& x);
5*e3723e1fSApple OSS Distributions //
6*e3723e1fSApple OSS Distributions // template <typename T, typename Alloc, typename TrappingPolicy>
7*e3723e1fSApple OSS Distributions // bool operator!=(std::nullptr_t, safe_allocation<T, Alloc, TrappingPolicy> const& x);
8*e3723e1fSApple OSS Distributions //
9*e3723e1fSApple OSS Distributions // template <typename T, typename Alloc, typename TrappingPolicy>
10*e3723e1fSApple OSS Distributions // bool operator==(safe_allocation<T, Alloc, TrappingPolicy> const& x, std::nullptr_t);
11*e3723e1fSApple OSS Distributions //
12*e3723e1fSApple OSS Distributions // template <typename T, typename Alloc, typename TrappingPolicy>
13*e3723e1fSApple OSS Distributions // bool operator!=(safe_allocation<T, Alloc, TrappingPolicy> const& x, std::nullptr_t);
14*e3723e1fSApple OSS Distributions //
15*e3723e1fSApple OSS Distributions
16*e3723e1fSApple OSS Distributions #include <libkern/c++/safe_allocation.h>
17*e3723e1fSApple OSS Distributions #include <darwintest.h>
18*e3723e1fSApple OSS Distributions #include "test_utils.h"
19*e3723e1fSApple OSS Distributions
20*e3723e1fSApple OSS Distributions struct T { };
21*e3723e1fSApple OSS Distributions
22*e3723e1fSApple OSS Distributions template <typename T>
23*e3723e1fSApple OSS Distributions static void
tests()24*e3723e1fSApple OSS Distributions tests()
25*e3723e1fSApple OSS Distributions {
26*e3723e1fSApple OSS Distributions {
27*e3723e1fSApple OSS Distributions test_safe_allocation<T> const array(10, libkern::allocate_memory);
28*e3723e1fSApple OSS Distributions CHECK(!(array == nullptr));
29*e3723e1fSApple OSS Distributions CHECK(!(nullptr == array));
30*e3723e1fSApple OSS Distributions CHECK(array != nullptr);
31*e3723e1fSApple OSS Distributions CHECK(nullptr != array);
32*e3723e1fSApple OSS Distributions }
33*e3723e1fSApple OSS Distributions {
34*e3723e1fSApple OSS Distributions test_safe_allocation<T> const array = nullptr;
35*e3723e1fSApple OSS Distributions CHECK(array == nullptr);
36*e3723e1fSApple OSS Distributions CHECK(nullptr == array);
37*e3723e1fSApple OSS Distributions CHECK(!(array != nullptr));
38*e3723e1fSApple OSS Distributions CHECK(!(nullptr != array));
39*e3723e1fSApple OSS Distributions }
40*e3723e1fSApple OSS Distributions }
41*e3723e1fSApple OSS Distributions
42*e3723e1fSApple OSS Distributions T_DECL(compare_equal_nullptr, "safe_allocation.compare.equal.nullptr", T_META_TAG_VM_PREFERRED) {
43*e3723e1fSApple OSS Distributions tests<T>();
44*e3723e1fSApple OSS Distributions tests<T const>();
45*e3723e1fSApple OSS Distributions }
46