#include "test.h" #include const UnitTest TESTS[] = { (UnitTest) { .Name = "Arena out of mem", .Function = ArenaOutOfMemory }, (UnitTest) { .Name = "Arena allocation", .Function = ArenaAllocation }, (UnitTest) { .Name = "Test difficulty calculation", .Function = difficultyCalculator}, }; 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; }