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