From d16a1385efe911b1683e390f672cadee78b842be Mon Sep 17 00:00:00 2001 From: physick Date: Wed, 12 Aug 2026 18:33:52 +0500 Subject: test system --- src/tests/runner.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/tests/runner.c (limited to 'src/tests/runner.c') 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 + +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; +} -- cgit v1.3