aboutsummaryrefslogtreecommitdiff
path: root/tests/include/minunit.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/include/minunit.h')
-rw-r--r--tests/include/minunit.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/include/minunit.h b/tests/include/minunit.h
index 9e2328f..204b321 100644
--- a/tests/include/minunit.h
+++ b/tests/include/minunit.h
@@ -18,13 +18,27 @@
#include "dbg.h"
#include <stdlib.h>
+/**
+ * Start the unit testing suite by creating an empty message
+ */
#define mu_suite_start() char *message = NULL
+/**
+ * Check a condition and log the message as an error if it fails
+ */
#define mu_assert(test, message) if (!(test)) { log_err(message); return message; }
+/**
+ * Run a test function, return the message if there is one, increment
+ * tests_run
+ */
#define mu_run_test(test) debug("\n-----%s", " " #test); \
message = test(); tests_run++; if (message) return message;
+/**
+ * Definition of main function for the test framework. Defines the output
+ * presented to stdout/stderr and runs all_tests function provided by "name"
+ */
#define RUN_TESTS(name) int main(int argc, char *argv[]) {\
argc = 1; \
debug("\n-----\nRUNNING: %s", argv[0]);\
@@ -40,9 +54,15 @@
exit(result != 0);\
}
+/**
+ * Log a warning to stdout when a test is missing and reduce tests_run by 1.
+ */
#define mu_test_missing() printf("\033[33;1mWARNING: Test missing\033[0m\n");\
tests_run--;
+/**
+ * Global counter for the number of tests that have been run.
+ */
int tests_run;
#endif