From fc479d1e20f7810626f22f9c2acfae8632508a0e Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Sun, 21 Jul 2019 11:47:12 +0200 Subject: [PATCH] TestSuite: instance() -> the(), and return a reference To be more consistent with the rest of the codebase --- AK/TestSuite.h | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/AK/TestSuite.h b/AK/TestSuite.h index 409e0281524..14be03cb3fe 100644 --- a/AK/TestSuite.h +++ b/AK/TestSuite.h @@ -73,11 +73,11 @@ private: class TestSuite { public: - static TestSuite* instance() + static TestSuite& the() { if (s_global == nullptr) s_global = new TestSuite(); - return s_global; + return *s_global; } void run(const NonnullRefPtrVector& tests); void main(const String& suite_name, int argc, char** argv); @@ -193,24 +193,24 @@ using AK::TestSuite; #define TESTCASE_TYPE_NAME(x) TestCase_##x /*! Define a test case function. */ -#define TEST_CASE(x) \ - static void x(); \ - struct TESTCASE_TYPE_NAME(x) { \ - TESTCASE_TYPE_NAME(x) \ - () { TestSuite::instance()->add_case(adopt(*new TestCase(___str(x), x, false))); } \ - }; \ - static struct TESTCASE_TYPE_NAME(x) TESTCASE_TYPE_NAME(x); \ +#define TEST_CASE(x) \ + static void x(); \ + struct TESTCASE_TYPE_NAME(x) { \ + TESTCASE_TYPE_NAME(x) \ + () { TestSuite::the().add_case(adopt(*new TestCase(___str(x), x, false))); } \ + }; \ + static struct TESTCASE_TYPE_NAME(x) TESTCASE_TYPE_NAME(x); \ static void x() #define BENCHMARK_TYPE_NAME(x) TestCase_##x -#define BENCHMARK_CASE(x) \ - static void x(); \ - struct BENCHMARK_TYPE_NAME(x) { \ - BENCHMARK_TYPE_NAME(x) \ - () { TestSuite::instance()->add_case(adopt(*new TestCase(___str(x), x, true))); } \ - }; \ - static struct BENCHMARK_TYPE_NAME(x) BENCHMARK_TYPE_NAME(x); \ +#define BENCHMARK_CASE(x) \ + static void x(); \ + struct BENCHMARK_TYPE_NAME(x) { \ + BENCHMARK_TYPE_NAME(x) \ + () { TestSuite::the().add_case(adopt(*new TestCase(___str(x), x, true))); } \ + }; \ + static struct BENCHMARK_TYPE_NAME(x) BENCHMARK_TYPE_NAME(x); \ static void x() /*! Define the main function of the testsuite. All TEST_CASE functions will be executed. */ @@ -224,7 +224,7 @@ using AK::TestSuite; int main(int argc, char** argv) \ { \ static_assert(compiletime_lenof(___str(SuiteName)) != 0, "Set SuiteName"); \ - TestSuite::instance()->main(___str(SuiteName), argc, argv); \ + TestSuite::the().main(___str(SuiteName), argc, argv); \ } #define assertEqual(one, two) \