summaryrefslogtreecommitdiffstats
path: root/test/ensure.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2023-09-22 23:12:28 -0400
committerDavid Robillard <d@drobilla.net>2023-09-22 23:12:28 -0400
commite2e65a8c8b816a066da1f7a4843ca7f504c2b3d9 (patch)
tree5ba3dcd7dcf753067b5ee45e1ce42b30aca2e090 /test/ensure.h
parent9f2e5b963c17a13303456dd46e13fc7c2ef32039 (diff)
downloadzix-e2e65a8c8b816a066da1f7a4843ca7f504c2b3d9.tar.gz
zix-e2e65a8c8b816a066da1f7a4843ca7f504c2b3d9.tar.bz2
zix-e2e65a8c8b816a066da1f7a4843ca7f504c2b3d9.zip
Improve test suite code coverage
Diffstat (limited to 'test/ensure.h')
-rw-r--r--test/ensure.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/ensure.h b/test/ensure.h
new file mode 100644
index 0000000..b906a1d
--- /dev/null
+++ b/test/ensure.h
@@ -0,0 +1,21 @@
+// Copyright 2023 David Robillard <d@drobilla.net>
+// SPDX-License-Identifier: ISC
+
+#ifndef ZIX_TEST_ENSURE_H
+#define ZIX_TEST_ENSURE_H
+
+#define ENSURE(ctx, condition, fmt) \
+ do { \
+ if (!(condition)) { \
+ return test_fail(ctx, fmt); \
+ } \
+ } while (0)
+
+#define ENSUREV(ctx, condition, fmt, ...) \
+ do { \
+ if (!(condition)) { \
+ return test_fail(ctx, fmt, __VA_ARGS__); \
+ } \
+ } while (0)
+
+#endif // ZIX_TEST_ENSURE_H