diff options
author | rsiddharth <s@ricketyspace.net> | 2019-08-24 19:26:17 -0400 |
---|---|---|
committer | rsiddharth <s@ricketyspace.net> | 2020-04-17 20:56:33 -0400 |
commit | 0c5b08ea58f88252e950ecaf40125a22b79fa83c (patch) | |
tree | 89508d0e0d6afc6cb6379bde9139777af5341160 /nserver/tests/minunit.h |
Add nserver.
For now it contains only "statserve".
Diffstat (limited to 'nserver/tests/minunit.h')
-rw-r--r-- | nserver/tests/minunit.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/nserver/tests/minunit.h b/nserver/tests/minunit.h new file mode 100644 index 0000000..a7cb280 --- /dev/null +++ b/nserver/tests/minunit.h @@ -0,0 +1,33 @@ +#undef NDEBUG +#ifndef _minunit_h +#define _minunit_h + +#include <stdio.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("----- 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);\ + exit(result != 0);\ + } + +int tests_run; + +#endif |