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