aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/curlcheck.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/curlcheck.h')
-rw-r--r--tests/unit/curlcheck.h50
1 files changed, 45 insertions, 5 deletions
diff --git a/tests/unit/curlcheck.h b/tests/unit/curlcheck.h
index 9d738430c..4b4d32c8d 100644
--- a/tests/unit/curlcheck.h
+++ b/tests/unit/curlcheck.h
@@ -1,14 +1,27 @@
-/*****************************************************************************
+/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- */
-
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at http://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
#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,18 +52,45 @@
} 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;
#define UNITTEST_START \
- int test(char *unused) \
+ int test(char *arg) \
{ \
- (void)unused; \
+ (void)arg; \
if (unit_setup()) { \
fail("unit_setup() failure"); \
} else {
#define UNITTEST_STOP \
+ goto unit_test_abort; /* avoid warning */ \
+unit_test_abort: \
unit_stop(); \
} \
return unitfail; \