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