1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 16:07:45 +00:00

LibTest: Add TEST_SETUP macro that runs before all test cases

This commit is contained in:
Peter Elliott 2021-08-29 11:55:05 -07:00 committed by Andreas Kling
parent b0bd4be59a
commit 83680934e5
3 changed files with 22 additions and 1 deletions

View file

@ -39,9 +39,17 @@ private:
// Helper to hide implementation of TestSuite from users
void add_test_case_to_suite(const NonnullRefPtr<TestCase>& test_case);
void set_suite_setup_function(Function<void()> setup);
}
#define TEST_SETUP \
static void __setup(); \
struct __setup_type { \
__setup_type() { Test::set_suite_setup_function(__setup); } \
}; \
static struct __setup_type __setup_type; \
static void __setup()
#define __TESTCASE_FUNC(x) __test_##x
#define __TESTCASE_TYPE(x) __TestCase_##x