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