summaryrefslogtreecommitdiff
path: root/src/tests/runner.c
diff options
context:
space:
mode:
authorphysick <mynameisgennadiy@vk.com>2026-08-12 18:33:52 +0500
committerphysick <mynameisgennadiy@vk.com>2026-08-29 14:17:03 +0500
commitd16a1385efe911b1683e390f672cadee78b842be (patch)
tree9c4a5e8a01952befa6b48c8fee4bd7471dbf421f /src/tests/runner.c
parentb1b2586afa06105291355a19f581016c347463bc (diff)
test system
Diffstat (limited to 'src/tests/runner.c')
-rw-r--r--src/tests/runner.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/tests/runner.c b/src/tests/runner.c
new file mode 100644
index 0000000..68c17bf
--- /dev/null
+++ b/src/tests/runner.c
@@ -0,0 +1,37 @@
+#include "test.h"
+#include <stdio.h>
+
+const UnitTest TESTS[] = {
+ (UnitTest) { .Name = "Arena out of mem", .Function = ArenaOutOfMemory },
+ (UnitTest) { .Name = "Arena allocation", .Function = ArenaAllocation },
+};
+
+void SetGreenColor() {
+ printf("\x1b[32m");
+}
+
+void SetRedColor() {
+ printf("\x1b[31m");
+}
+
+void ResetColor() {
+ printf("\x1b[39m");
+}
+
+int main(void) {
+ size_t length = sizeof(TESTS) / sizeof(TESTS[0]);
+ SetGreenColor();
+ for (size_t i = 0; i < length; ++i) {
+ const UnitTest *test = &TESTS[i];
+ char *outp = test->Function();
+ if (outp == NULL) {
+ printf("Test '%s' passed\n", test->Name);
+ } else {
+ SetRedColor();
+ printf("test '%s' failed: %s\n", test->Name, outp);
+ return 1;
+ }
+ }
+ ResetColor();
+ return 0;
+}