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