Simplified macro to define a conditional test.
19 {
20
26 PASS,
27 FAIL,
28 SKIP
29 };
30
36 COMMON,
37 DRIVER,
38 FILESYSTEM,
39 GUI,
40 HARDWARE_COMMUNICATION,
41 MEMORY,
42 NETWORK,
43 PROCESSES,
44 RUNTIME,
45 SYSTEM,
46 MAX_TEST_TYPES
47 };
48
51 "COMMON",
52 "DRIVER",
53 "FILESYSTEM",
54 "GUI",
55 "HARDWARE_COMMUNICATION",
56 "MEMORY",
57 "NETWORK",
58 "PROCESSES",
59 "RUNTIME",
60 "SYSTEM",
61 "UNKNOWN"
62 };
63
68 class Test {
69
70 private:
71 string m_name;
73
74 public:
75 Test(const string& name, TestType type);
76 virtual ~Test();
77
79
86
87 const string& name() const;
89 };
90
100 template<
typename T1,
typename T2>
bool compare(T1
const& actual, T2
const& expected) {
101
102
103 if (actual == expected)
104 return true;
105
106
107 Logger::WARNING() << "Test failed comparison: expected [" << expected << "], got [" << actual << "]\n";
108 return false;
109 }
110
115 class ConditionalTest : public Test {
116 private:
117 bool (*m_condition)();
118
119 public:
120 ConditionalTest(const string& name, TestType type, bool (*condition)());
121 ~ConditionalTest() override;
122
124 };
125
132 class TestRunner {
133
134 private:
135 inline static common::Vector<Test*> s_tests = common::Vector<Test*>();
136
137 public:
138
139 static void test_kernel();
140
141 static void run_all_tests();
142 static void run_all_types(TestType type);
143
144 static void add_all_tests();
145 static void add_test(Test* test);
146
147 };
148}
149
150#endif
constexpr const char * TEST_TYPE_STRINGS[]
String representations of the TestType enum.
TestType
The different types of tests.
TestStatus
The possible outcomes of a test.
bool compare(T1 const &actual, T2 const &expected)
Compares two values and logs a warning if they are not equal.