49 const char *
const descr;
50 const char *
const test_file;
58typedef void (*unit_test_report_function_t)(
const unit_test_t *);
70#define UNIT_TEST_REGISTER(name, description) \
71 static unit_test_t unit_test_##name = \
72 {.descr = (description), \
73 .test_file = __FILE__, \
100#define UNIT_TEST(name) \
101 PT_THREAD(unit_test_function_##name(unit_test_t *unit_test_ptr))
106#define UNIT_TEST_BEGIN() PT_BEGIN(&unit_test_pt); \
107 unit_test_ptr->start = clock_time(); \
108 unit_test_ptr->assertions = 0; \
109 unit_test_ptr->passed = true
114#define UNIT_TEST_END() UNIT_TEST_SUCCEED(); \
116 unit_test_ptr->end = clock_time(); \
117 PT_END(&unit_test_pt)
125#ifndef UNIT_TEST_PRINT_FUNCTION
126#define UNIT_TEST_PRINT_FUNCTION unit_test_print_report
134#define UNIT_TEST_PRINT_REPORT(name) UNIT_TEST_PRINT_FUNCTION(&unit_test_##name)
141#define UNIT_TEST_RUN(name) do { \
142 PROCESS_PT_SPAWN(&unit_test_pt, \
143 unit_test_function_##name( \
144 &unit_test_##name)); \
145 UNIT_TEST_PRINT_REPORT(name); \
159#define UNIT_TEST_SUCCEED() do { \
160 unit_test_ptr->exit_line = __LINE__; \
161 goto unit_test_end; \
171#define UNIT_TEST_FAIL() do { \
172 unit_test_ptr->exit_line = __LINE__; \
173 unit_test_ptr->passed = false; \
174 goto unit_test_end; \
182#define UNIT_TEST_ASSERT(expr) do { \
183 unit_test_ptr->assertions++; \
199#define UNIT_TEST_PASSED(name) (unit_test_##name.passed)
202void UNIT_TEST_PRINT_FUNCTION(
const unit_test_t *unit_test_ptr);
204extern struct pt unit_test_pt;
The unit_test structure describes the results of a unit test.
struct unit_test unit_test_t
The unit_test structure describes the results of a unit test.