From 35e1d6538a8767526b9cae66134441b146503a21 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 1 Jan 2011 17:33:42 +0100 Subject: unittest: framework for unit-testing This is the first approach at doing fairly clean and easy to write and debug unit tests. --- tests/unit/curlcheck.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/unit/curlcheck.h (limited to 'tests/unit/curlcheck.h') diff --git a/tests/unit/curlcheck.h b/tests/unit/curlcheck.h new file mode 100644 index 000000000..c34f99093 --- /dev/null +++ b/tests/unit/curlcheck.h @@ -0,0 +1,31 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + */ + +#include "test.h" + +#define fail_unless(expr, msg) \ + if(!(expr)) { \ + fprintf(stderr, "%s:%d Assertion '%s' failed: %s" , \ + __FILE__, __LINE__, #expr, msg); \ + unitfail++; \ + } + +extern int unitfail; + +#define UNITTEST_START \ + int test(char *unused) \ + { \ + (void)unused; \ + unit_setup(); + +#define UNITTEST_STOP \ + unit_stop(); \ + return unitfail; \ + } + -- cgit v1.2.3