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