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