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