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