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