summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2015-05-24 22:34:05 +0100
committerMaxime Coste <frrrwww@gmail.com>2015-05-24 22:34:05 +0100
commit41319d2708bb311b2bd0b82ec310ae985f9b5861 (patch)
tree07fc761cbba97b53fe1e6d535f0b10ceb350ce34 /src
parentccfb87ecf39592b2cf4fa00cdbd53098594c26f2 (diff)
Small refactor in unit tests
Diffstat (limited to 'src')
-rw-r--r--src/main.cc2
-rw-r--r--src/unit_tests.cc6
-rw-r--r--src/unit_tests.hh10
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;
+};
}