xref: /xnu-10002.61.3/tests/bounded_array_ref_src/compare.equal.nullptr.cpp (revision 0f4c859e951fba394238ab619495c4e1d54d0f34)
1*0f4c859eSApple OSS Distributions //
2*0f4c859eSApple OSS Distributions // Tests for
3*0f4c859eSApple OSS Distributions //  template <typename T, typename P>
4*0f4c859eSApple OSS Distributions //  bool operator==(bounded_array_ref<T, P> const& x, std::nullptr_t);
5*0f4c859eSApple OSS Distributions //
6*0f4c859eSApple OSS Distributions //  template <typename T, typename P>
7*0f4c859eSApple OSS Distributions //  bool operator!=(bounded_array_ref<T, P> const& x, std::nullptr_t);
8*0f4c859eSApple OSS Distributions //
9*0f4c859eSApple OSS Distributions //  template <typename T, typename P>
10*0f4c859eSApple OSS Distributions //  bool operator==(std::nullptr_t, bounded_array_ref<T, P> const& x);
11*0f4c859eSApple OSS Distributions //
12*0f4c859eSApple OSS Distributions //  template <typename T, typename P>
13*0f4c859eSApple OSS Distributions //  bool operator!=(std::nullptr_t, bounded_array_ref<T, P> const& x);
14*0f4c859eSApple OSS Distributions //
15*0f4c859eSApple OSS Distributions 
16*0f4c859eSApple OSS Distributions #include <libkern/c++/bounded_array_ref.h>
17*0f4c859eSApple OSS Distributions #include "test_policy.h"
18*0f4c859eSApple OSS Distributions #include <darwintest.h>
19*0f4c859eSApple OSS Distributions #include <darwintest_utils.h>
20*0f4c859eSApple OSS Distributions 
21*0f4c859eSApple OSS Distributions struct T { int i; };
22*0f4c859eSApple OSS Distributions 
23*0f4c859eSApple OSS Distributions template <typename T>
24*0f4c859eSApple OSS Distributions static void
tests()25*0f4c859eSApple OSS Distributions tests()
26*0f4c859eSApple OSS Distributions {
27*0f4c859eSApple OSS Distributions 	{
28*0f4c859eSApple OSS Distributions 		T array[5] = {T{0}, T{1}, T{2}, T{3}, T{4}};
29*0f4c859eSApple OSS Distributions 		test_bounded_array_ref<T> view(array);
30*0f4c859eSApple OSS Distributions 		CHECK(!(view == nullptr));
31*0f4c859eSApple OSS Distributions 		CHECK(!(nullptr == view));
32*0f4c859eSApple OSS Distributions 		CHECK(view != nullptr);
33*0f4c859eSApple OSS Distributions 		CHECK(nullptr != view);
34*0f4c859eSApple OSS Distributions 	}
35*0f4c859eSApple OSS Distributions 	{
36*0f4c859eSApple OSS Distributions 		test_bounded_array_ref<T> view;
37*0f4c859eSApple OSS Distributions 		CHECK(view == nullptr);
38*0f4c859eSApple OSS Distributions 		CHECK(nullptr == view);
39*0f4c859eSApple OSS Distributions 		CHECK(!(view != nullptr));
40*0f4c859eSApple OSS Distributions 		CHECK(!(nullptr != view));
41*0f4c859eSApple OSS Distributions 	}
42*0f4c859eSApple OSS Distributions }
43*0f4c859eSApple OSS Distributions 
44*0f4c859eSApple OSS Distributions T_DECL(compare_equal_nullptr, "bounded_array_ref.compare.equal.nullptr") {
45*0f4c859eSApple OSS Distributions 	tests<T>();
46*0f4c859eSApple OSS Distributions }
47