summaryrefslogtreecommitdiffstats
path: root/test/ensure.h
diff options
context:
space:
mode:
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