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