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