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