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