From ddc438619295b1a2d7035277f24023aa262d6ed9 Mon Sep 17 00:00:00 2001 From: tmeissner Date: Thu, 24 Apr 2014 09:48:30 +0200 Subject: [PATCH] initial commit of MinUnit test 'framework' --- c_pointers/minunit.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 c_pointers/minunit.h diff --git a/c_pointers/minunit.h b/c_pointers/minunit.h new file mode 100644 index 0000000..427d7bc --- /dev/null +++ b/c_pointers/minunit.h @@ -0,0 +1,16 @@ +// MinUnit test framework +// taken from http://www.jera.com/techinfo/jtns/jtn002.html +// slightly expanded, see http://stackoverflow.com/a/22732645 + +#include +#include + +#define mu_assert(message, test) do {if (!(test)) return message;} while (0) +#define mu_run_test(test) do {char *message = test(); tests_run++; if (message) return message;} while (0) + +#define clean_errno() (errno == 0 ? "None" : strerror(errno)) +#define log_error(M, ...) fprintf(stderr, "[ERROR] (%s:%d: errno: %s) " M "\n", __FILE__, __LINE__, clean_errno(), ##__VA_ARGS__) +#define assertf(A, M, ...) if(!(A)) {log_error(M, ##__VA_ARGS__); assert(A); } + + +extern int tests_run; \ No newline at end of file