]> git.saurik.com Git - apple/xnu.git/blame - tests/bounded_array_ref_src/test_policy.h
xnu-7195.81.3.tar.gz
[apple/xnu.git] / tests / bounded_array_ref_src / test_policy.h
CommitLineData
f427ee49
A
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
12namespace {
13struct test_policy {
14 static void
15 trap(char const*)
16 {
17 assert(false);
18 }
19};
20
21struct tracking_policy {
22 static bool did_trap;
23 static std::string message;
24 static void
25 trap(char const* m)
26 {
27 did_trap = true;
28 message.assign(m);
29 }
30 static void
31 reset()
32 {
33 did_trap = false;
34 message = "";
35 }
36};
37bool tracking_policy::did_trap = false;
38std::string tracking_policy::message = "";
39}
40
41template <typename T>
42using test_bounded_array_ref = libkern::bounded_array_ref<T, test_policy>;
43
44template <typename T, size_t N>
45using test_bounded_array = libkern::bounded_array<T, N, test_policy>;
46
47template <typename T>
48using 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