aboutsummaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorDan Fandrich <dan@coneharvesters.com>2011-03-04 13:53:15 -0800
committerDan Fandrich <dan@coneharvesters.com>2011-03-04 13:53:15 -0800
commit32aedf1d3d17fb2103c6a2ee3642a25a6086c68e (patch)
treee03c4b96944896294691de1e68eb6e201791769e /tests/unit
parent8511b6436c4e1c6303cc0cb9b41677628289f41a (diff)
Added abort_* unit test macros
These are for when a test failure makes it impossible to continue running further tests.
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/curlcheck.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/unit/curlcheck.h b/tests/unit/curlcheck.h
index 9d738430c..9525dd6fb 100644
--- a/tests/unit/curlcheck.h
+++ b/tests/unit/curlcheck.h
@@ -9,6 +9,7 @@
#include "test.h"
+/* The fail macros mark the current test step as failed, and continue */
#define fail_if(expr, msg) \
if(expr) { \
fprintf(stderr, "%s:%d Assertion '%s' met: %s\n" , \
@@ -39,6 +40,31 @@
} while(0)
+/* The abort macros mark the current test step as failed, and exit the test */
+#define abort_if(expr, msg) \
+ if(expr) { \
+ fprintf(stderr, "%s:%d Abort assertion '%s' met: %s\n" , \
+ __FILE__, __LINE__, #expr, msg); \
+ unitfail++; \
+ goto unit_test_abort; \
+ }
+
+#define abort_unless(expr, msg) \
+ if(!(expr)) { \
+ fprintf(stderr, "%s:%d Abort assertion '%s' failed: %s\n", \
+ __FILE__, __LINE__, #expr, msg); \
+ unitfail++; \
+ goto unit_test_abort; \
+ }
+
+#define abort_test(msg) do { \
+ fprintf(stderr, "%s:%d test aborted: '%s'\n", \
+ __FILE__, __LINE__, msg); \
+ unitfail++; \
+ goto unit_test_abort; \
+ } while(0)
+
+
extern int unitfail;
@@ -51,6 +77,8 @@ extern int unitfail;
} else {
#define UNITTEST_STOP \
+ goto unit_test_abort; /* avoid warning */ \
+unit_test_abort: \
unit_stop(); \
} \
return unitfail; \