1*2c2f96dcSApple OSS Distributions #ifndef TESTS_BOUNDED_ARRAY_REF_SRC_TEST_POLICY_H 2*2c2f96dcSApple OSS Distributions #define TESTS_BOUNDED_ARRAY_REF_SRC_TEST_POLICY_H 3*2c2f96dcSApple OSS Distributions 4*2c2f96dcSApple OSS Distributions #include <assert.h> 5*2c2f96dcSApple OSS Distributions #include <darwintest_utils.h> 6*2c2f96dcSApple OSS Distributions #include <libkern/c++/bounded_array.h> 7*2c2f96dcSApple OSS Distributions #include <libkern/c++/bounded_array_ref.h> 8*2c2f96dcSApple OSS Distributions #include <libkern/c++/bounded_ptr.h> 9*2c2f96dcSApple OSS Distributions #include <stddef.h> 10*2c2f96dcSApple OSS Distributions #include <string> 11*2c2f96dcSApple OSS Distributions 12*2c2f96dcSApple OSS Distributions namespace { 13*2c2f96dcSApple OSS Distributions struct test_policy { 14*2c2f96dcSApple OSS Distributions static void traptest_policy15*2c2f96dcSApple OSS Distributions trap(char const*) 16*2c2f96dcSApple OSS Distributions { 17*2c2f96dcSApple OSS Distributions assert(false); 18*2c2f96dcSApple OSS Distributions } 19*2c2f96dcSApple OSS Distributions }; 20*2c2f96dcSApple OSS Distributions 21*2c2f96dcSApple OSS Distributions struct tracking_policy { 22*2c2f96dcSApple OSS Distributions static bool did_trap; 23*2c2f96dcSApple OSS Distributions static std::string message; 24*2c2f96dcSApple OSS Distributions static void traptracking_policy25*2c2f96dcSApple OSS Distributions trap(char const* m) 26*2c2f96dcSApple OSS Distributions { 27*2c2f96dcSApple OSS Distributions did_trap = true; 28*2c2f96dcSApple OSS Distributions message.assign(m); 29*2c2f96dcSApple OSS Distributions } 30*2c2f96dcSApple OSS Distributions static void resettracking_policy31*2c2f96dcSApple OSS Distributions reset() 32*2c2f96dcSApple OSS Distributions { 33*2c2f96dcSApple OSS Distributions did_trap = false; 34*2c2f96dcSApple OSS Distributions message = ""; 35*2c2f96dcSApple OSS Distributions } 36*2c2f96dcSApple OSS Distributions }; 37*2c2f96dcSApple OSS Distributions bool tracking_policy::did_trap = false; 38*2c2f96dcSApple OSS Distributions std::string tracking_policy::message = ""; 39*2c2f96dcSApple OSS Distributions } 40*2c2f96dcSApple OSS Distributions 41*2c2f96dcSApple OSS Distributions template <typename T> 42*2c2f96dcSApple OSS Distributions using test_bounded_array_ref = libkern::bounded_array_ref<T, test_policy>; 43*2c2f96dcSApple OSS Distributions 44*2c2f96dcSApple OSS Distributions template <typename T, size_t N> 45*2c2f96dcSApple OSS Distributions using test_bounded_array = libkern::bounded_array<T, N, test_policy>; 46*2c2f96dcSApple OSS Distributions 47*2c2f96dcSApple OSS Distributions template <typename T> 48*2c2f96dcSApple OSS Distributions using test_bounded_ptr = libkern::bounded_ptr<T, test_policy>; 49*2c2f96dcSApple OSS Distributions 50*2c2f96dcSApple OSS Distributions #define CHECK(...) T_ASSERT_TRUE((__VA_ARGS__), # __VA_ARGS__) 51*2c2f96dcSApple OSS Distributions 52*2c2f96dcSApple OSS Distributions #endif // !TESTS_BOUNDED_ARRAY_REF_SRC_TEST_POLICY_H 53