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