diff options
Diffstat (limited to 'src/tests/runner.c')
| -rw-r--r-- | src/tests/runner.c | 37 |
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; +} |
