aboutsummaryrefslogtreecommitdiff
path: root/tests/testutil.h
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2019-12-27 15:57:34 -0800
committerGarrett D'Amore <garrett@damore.org>2019-12-27 15:57:34 -0800
commit7c6ce24b028a8c201ac8eb1513a6424205c4d8d8 (patch)
treefdc15b7636c22f0c27b65f055be8743392d4726c /tests/testutil.h
parenta1e169b05e24c30d2936c1b3cad18c7b604e3099 (diff)
downloadnng-7c6ce24b028a8c201ac8eb1513a6424205c4d8d8.tar.gz
nng-7c6ce24b028a8c201ac8eb1513a6424205c4d8d8.tar.bz2
nng-7c6ce24b028a8c201ac8eb1513a6424205c4d8d8.zip
fixes #1042 testutil.h could offer better test failure diagnosis
Diffstat (limited to 'tests/testutil.h')
-rw-r--r--tests/testutil.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/testutil.h b/tests/testutil.h
index 97540f36..b3c3bbd2 100644
--- a/tests/testutil.h
+++ b/tests/testutil.h
@@ -42,6 +42,24 @@ extern uint16_t testutil_next_port(void);
// are fully connected.
extern int testutil_marry(nng_socket, nng_socket);
+// TEST_NNG_PASS tests for NNG success. It reports the failure if it
+// did not.
+#define TEST_NNG_PASS(cond) \
+ do { \
+ int result_ = (cond); \
+ TEST_CHECK_(result_ == 0, "%s failed: %s (%d)", #cond, \
+ nng_strerror(result_), result_); \
+ } while (0)
+
+#define TEST_NNG_FAIL(cond, expect) \
+ do { \
+ int result_ = (cond); \
+ TEST_CHECK_(result_ == expect, \
+ "%s: expected %s (%d), got %s (%d)", #cond, \
+ nng_strerror(expect), expect, nng_strerror(result_), \
+ result_); \
+ } while (0)
+
#ifdef __cplusplus
};
#endif