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