tests: Better suite creation
While the previous method of in-lining a stack allocated array of tests into the suite struct declaration was nice, we had to update size manually. This macro will allow us to just append new tests to the suite without having to care for that. It generates a uniquely named variable for the test array, then uses that test array in the suite declaration. Nice and easy.
This commit is contained in:
@@ -61,8 +61,13 @@ typedef struct
|
||||
const u64 size;
|
||||
} test_suite_t;
|
||||
|
||||
#define MAKE_TEST_SUITE(NAME) \
|
||||
{.name = #NAME, .tests = NAME, .size = ARRSIZE(NAME)}
|
||||
#define MAKE_TEST_SUITE(NAME, DESC, ...) \
|
||||
const test_fn NAME##_TESTS[] = {__VA_ARGS__}; \
|
||||
const test_suite_t NAME = { \
|
||||
.name = DESC, \
|
||||
.tests = NAME##_TESTS, \
|
||||
.size = ARRSIZE(NAME##_TESTS), \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user