summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2024-07-17 22:29:46 +1000
committerMaxime Coste <mawww@kakoune.org>2024-07-21 00:50:02 +1000
commita5ba9bb45f368d88a42f08e4d3134e408f81ab05 (patch)
tree96898ec3519d2704fd7e17864aab725abff236d7 /src
parent011283e4d2579d905738ef8684972071faad1b7e (diff)
Disable UnitTest fully in non KAK_DEBUG builds
The code was still compiled and stored in the release executable, this reduces the optimized binary size.
Diffstat (limited to 'src')
-rw-r--r--src/unit_tests.cc2
-rw-r--r--src/unit_tests.hh4
2 files changed, 6 insertions, 0 deletions
diff --git a/src/unit_tests.cc b/src/unit_tests.cc
index 7c77d508..1f63ff47 100644
--- a/src/unit_tests.cc
+++ b/src/unit_tests.cc
@@ -43,6 +43,7 @@ UnitTest test_diff{[]()
}};
+#ifdef KAK_DEBUG
UnitTest* UnitTest::list = nullptr;
void UnitTest::run_all_tests()
@@ -50,5 +51,6 @@ void UnitTest::run_all_tests()
for (const UnitTest* test = UnitTest::list; test; test = test->next)
test->func();
}
+#endif
}
diff --git a/src/unit_tests.hh b/src/unit_tests.hh
index 16162694..7072d885 100644
--- a/src/unit_tests.hh
+++ b/src/unit_tests.hh
@@ -6,12 +6,16 @@ namespace Kakoune
struct UnitTest
{
+#ifdef KAK_DEBUG
UnitTest(void (*func)()) : func(func), next(list) { list = this; }
void (*func)();
const UnitTest* next;
static void run_all_tests();
static UnitTest* list;
+#else
+ UnitTest(void (*func)()) {}
+#endif
};
}