xref: /xnu-8020.121.3/tests/bounded_array_src/test_policy.h (revision fdd8201d7b966f0c3ea610489d29bd841d358941)
1*fdd8201dSApple OSS Distributions #ifndef TESTS_BOUNDED_ARRAY_SRC_TEST_POLICY_H
2*fdd8201dSApple OSS Distributions #define TESTS_BOUNDED_ARRAY_SRC_TEST_POLICY_H
3*fdd8201dSApple OSS Distributions 
4*fdd8201dSApple OSS Distributions #include <assert.h>
5*fdd8201dSApple OSS Distributions #include <darwintest_utils.h>
6*fdd8201dSApple OSS Distributions #include <libkern/c++/bounded_array.h>
7*fdd8201dSApple OSS Distributions #include <libkern/c++/bounded_ptr.h>
8*fdd8201dSApple OSS Distributions #include <stddef.h>
9*fdd8201dSApple OSS Distributions 
10*fdd8201dSApple OSS Distributions struct test_policy {
11*fdd8201dSApple OSS Distributions 	static void
traptest_policy12*fdd8201dSApple OSS Distributions 	trap(char const*)
13*fdd8201dSApple OSS Distributions 	{
14*fdd8201dSApple OSS Distributions 		assert(false);
15*fdd8201dSApple OSS Distributions 	}
16*fdd8201dSApple OSS Distributions };
17*fdd8201dSApple OSS Distributions 
18*fdd8201dSApple OSS Distributions template <typename T, size_t N>
19*fdd8201dSApple OSS Distributions using test_bounded_array = libkern::bounded_array<T, N, test_policy>;
20*fdd8201dSApple OSS Distributions 
21*fdd8201dSApple OSS Distributions template <typename T>
22*fdd8201dSApple OSS Distributions using test_bounded_ptr = libkern::bounded_ptr<T, test_policy>;
23*fdd8201dSApple OSS Distributions 
24*fdd8201dSApple OSS Distributions #define CHECK(...) T_ASSERT_TRUE((__VA_ARGS__), # __VA_ARGS__)
25*fdd8201dSApple OSS Distributions 
26*fdd8201dSApple OSS Distributions #endif // !TESTS_BOUNDED_ARRAY_SRC_TEST_POLICY_H
27