diff options
| author | Gertjan van den Burg <gertjanvandenburg@gmail.com> | 2016-05-17 23:02:04 +0200 |
|---|---|---|
| committer | Gertjan van den Burg <gertjanvandenburg@gmail.com> | 2016-05-17 23:02:04 +0200 |
| commit | 7d9f7e9341ab22599ea541959dbf9323661c777f (patch) | |
| tree | 93b9262f64b606089b6b85aceafc47fa631887e8 /tests/include/minunit.h | |
| parent | make blas and lapack calls more compact (diff) | |
| download | gensvm-7d9f7e9341ab22599ea541959dbf9323661c777f.tar.gz gensvm-7d9f7e9341ab22599ea541959dbf9323661c777f.zip | |
start adding unit tests
Diffstat (limited to 'tests/include/minunit.h')
| -rw-r--r-- | tests/include/minunit.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/include/minunit.h b/tests/include/minunit.h new file mode 100644 index 0000000..4197310 --- /dev/null +++ b/tests/include/minunit.h @@ -0,0 +1,34 @@ +#undef NDEBUG +#ifndef _minunit_h +#define _minunit_h + +#include "dbg.h" +#include <stdlib.h> + +#define mu_suite_start() char *message = NULL + +#define mu_assert(test, message) if (!(test)) { log_err(message); return message; } + +#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 = 1; \ + debug("\n-----\nRUNNING: %s", argv[0]);\ + printf("----\nRUNNING: %s\n", argv[0]);\ + char *result = name();\ + if (result != 0) {\ + printf("\033[91mFAILED:\033[0m %s\n", result);\ + }\ + else {\ + printf("ALL TESTS \033[92mPASSED\033[0m\n");\ + }\ + printf("Tests run: %d\n", tests_run);\ + exit(result != 0);\ +} + +#define mu_test_missing() printf("\033[33;1mWARNING: Test missing\033[0m\n"); + +int tests_run; + +#endif |
