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