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