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