diff --git a/src/main.cc b/src/main.cc index 21be68d44..7b1f62f98 100644 --- a/src/main.cc +++ b/src/main.cc @@ -370,7 +370,7 @@ int run_server(StringView session, StringView init_command, FaceRegistry face_registry; ClientManager client_manager; - run_unit_tests(); + UnitTest::run_all_tests(); register_options(); register_env_vars(); diff --git a/src/unit_tests.cc b/src/unit_tests.cc index 5faf91a65..68518b518 100644 --- a/src/unit_tests.cc +++ b/src/unit_tests.cc @@ -42,11 +42,11 @@ UnitTest test_diff{[]() } }}; -UnitTest* unit_tests; +UnitTest* UnitTest::list = nullptr; -void run_unit_tests() +void UnitTest::run_all_tests() { - for (const UnitTest* test = unit_tests; test; test = test->next) + for (const UnitTest* test = UnitTest::list; test; test = test->next) test->func(); } diff --git a/src/unit_tests.hh b/src/unit_tests.hh index 1985a5935..161626945 100644 --- a/src/unit_tests.hh +++ b/src/unit_tests.hh @@ -4,17 +4,15 @@ namespace Kakoune { -struct UnitTest; -extern UnitTest* unit_tests; - struct UnitTest { - UnitTest(void (*func)()) : func(func), next(unit_tests) { unit_tests = this; } + UnitTest(void (*func)()) : func(func), next(list) { list = this; } void (*func)(); const UnitTest* next; -}; -void run_unit_tests(); + static void run_all_tests(); + static UnitTest* list; +}; }