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