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