-
Notifications
You must be signed in to change notification settings - Fork 0
/
minunit.h
31 lines (26 loc) · 935 Bytes
/
minunit.h
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
/* file: minunit.h */
#define mu_assert(message, test) do { if (!(test)) return message; } while (0)
#define mu_run_test(test) do { char *message = test(); tests_run++; \
if (message) return message; } while (0)
#define debug_printf(fmt, ...) \
do { if (DEBUG) fprintf(stderr, " DEBUG: %s:%d:%s(): " fmt, __FILE__, \
__LINE__, __func__, __VA_ARGS__); } while (0)
extern int tests_run;
static char* all_tests();
void run_tests();
int tests_run = 0;
void run_tests()
{
char* result = all_tests();
printf("===================\n");
printf("== Test Runner \n");
printf("===================\n");
if (result !=0) {
printf("TEST FAILED\n");
printf("%s\n", result);
} else {
printf("ALL TESTS PASSED\n");
}
printf("Tests run: %d\n", tests_run);
printf("===================\n");
}