From 41319d2708bb311b2bd0b82ec310ae985f9b5861 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 24 May 2015 22:34:05 +0100 Subject: [PATCH] Small refactor in unit tests --- src/main.cc | 2 +- src/unit_tests.cc | 6 +++--- src/unit_tests.hh | 10 ++++------ 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/main.cc b/src/main.cc index 21be68d4..7b1f62f9 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 5faf91a6..68518b51 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 1985a593..16162694 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; +}; }