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