39 lines
880 B
C
39 lines
880 B
C
#undef DNDEBUG
|
|
#ifndef _minunit_h
|
|
#define _minunit_h
|
|
|
|
#include <stdio.h>
|
|
#include <lcthw/dbg.h>
|
|
#include <stdlib.h>
|
|
|
|
#define mu_suite_start() char *message = NULL
|
|
|
|
#define mu_assert(test, message) if (!(test)) {\
|
|
log_err(message); return message;\
|
|
}\
|
|
assertions_made++;
|
|
#define mu_run_test(test) debug("\n-----%s", " " #test); \
|
|
message = test(); tests_run++; if (message) return message;
|
|
|
|
#define RUN_TESTS(name) int main(int argc, char *argv[]) {\
|
|
argc = argc; \
|
|
argv = argv; \
|
|
debug("----- RUNNING: %s", argv[0]);\
|
|
printf("----\nRUNNING: %s\n", argv[0]);\
|
|
char *result = name();\
|
|
if (result != 0) {\
|
|
printf("FAILED: %s\n", result);\
|
|
}\
|
|
else {\
|
|
printf("ALL TESTS PASSED\n");\
|
|
}\
|
|
printf("Tests run: %d\n", tests_run);\
|
|
printf("Assertions made: %d\n", assertions_made);\
|
|
exit(result != 0);\
|
|
}
|
|
|
|
int tests_run;
|
|
int assertions_made;
|
|
|
|
#endif
|