summaryrefslogtreecommitdiffstats
path: root/tests/minunit.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/minunit.h')
-rw-r--r--tests/minunit.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/minunit.h b/tests/minunit.h
new file mode 100644
index 0000000..4ddf265
--- /dev/null
+++ b/tests/minunit.h
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Copyright © 2010, Zed A. Shaw.
+ */
+
+#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