blob: 68c17bf22db5230b66bfa178e426cd4f917974fa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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;
}
|