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

TestSuite: instance() -> the(), and return a reference

To be more consistent with the rest of the codebase
This commit is contained in:
Robin Burchell 2019-07-21 11:47:12 +02:00 committed by Andreas Kling
parent fa6f601170
commit fc479d1e20

View file

@ -73,11 +73,11 @@ private:
class TestSuite { class TestSuite {
public: public:
static TestSuite* instance() static TestSuite& the()
{ {
if (s_global == nullptr) if (s_global == nullptr)
s_global = new TestSuite(); s_global = new TestSuite();
return s_global; return *s_global;
} }
void run(const NonnullRefPtrVector<TestCase>& tests); void run(const NonnullRefPtrVector<TestCase>& tests);
void main(const String& suite_name, int argc, char** argv); 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 TESTCASE_TYPE_NAME(x) TestCase_##x
/*! Define a test case function. */ /*! Define a test case function. */
#define TEST_CASE(x) \ #define TEST_CASE(x) \
static void x(); \ static void x(); \
struct TESTCASE_TYPE_NAME(x) { \ struct TESTCASE_TYPE_NAME(x) { \
TESTCASE_TYPE_NAME(x) \ TESTCASE_TYPE_NAME(x) \
() { TestSuite::instance()->add_case(adopt(*new TestCase(___str(x), x, false))); } \ () { TestSuite::the().add_case(adopt(*new TestCase(___str(x), x, false))); } \
}; \ }; \
static struct TESTCASE_TYPE_NAME(x) TESTCASE_TYPE_NAME(x); \ static struct TESTCASE_TYPE_NAME(x) TESTCASE_TYPE_NAME(x); \
static void x() static void x()
#define BENCHMARK_TYPE_NAME(x) TestCase_##x #define BENCHMARK_TYPE_NAME(x) TestCase_##x
#define BENCHMARK_CASE(x) \ #define BENCHMARK_CASE(x) \
static void x(); \ static void x(); \
struct BENCHMARK_TYPE_NAME(x) { \ struct BENCHMARK_TYPE_NAME(x) { \
BENCHMARK_TYPE_NAME(x) \ BENCHMARK_TYPE_NAME(x) \
() { TestSuite::instance()->add_case(adopt(*new TestCase(___str(x), x, true))); } \ () { TestSuite::the().add_case(adopt(*new TestCase(___str(x), x, true))); } \
}; \ }; \
static struct BENCHMARK_TYPE_NAME(x) BENCHMARK_TYPE_NAME(x); \ static struct BENCHMARK_TYPE_NAME(x) BENCHMARK_TYPE_NAME(x); \
static void x() static void x()
/*! Define the main function of the testsuite. All TEST_CASE functions will be executed. */ /*! 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) \ int main(int argc, char** argv) \
{ \ { \
static_assert(compiletime_lenof(___str(SuiteName)) != 0, "Set SuiteName"); \ 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) \ #define assertEqual(one, two) \