summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/tests.h33
1 files changed, 13 insertions, 20 deletions
diff --git a/tests/tests.h b/tests/tests.h
index d395c7c..cd5715f 100644
--- a/tests/tests.h
+++ b/tests/tests.h
@@ -8,6 +8,7 @@
#ifndef BFS_TESTS_H
#define BFS_TESTS_H
+#include "bfs.h"
#include "bfstd.h"
#include "diag.h"
@@ -44,31 +45,23 @@ bool bfs_check_impl(bool result);
/**
* Check a condition, logging a message on failure but continuing.
*/
-#define bfs_check(...) \
- bfs_check_(#__VA_ARGS__, __VA_ARGS__, "", )
+#define bfs_check(cond, ...) \
+ bfs_check_impl((cond) || (bfs_check_(#cond, __VA_ARGS__), false))
-#define bfs_check_(str, cond, format, ...) \
- bfs_check_impl((cond) || (bfs_check__(format, BFS_DIAG_MSG_(format, str), __VA_ARGS__), false))
-
-#define bfs_check__(format, ...) \
- bfs_diagf(sizeof(format) > 1 \
- ? BFS_DIAG_FORMAT_("%s" format "%s") \
- : BFS_DIAG_FORMAT_("Check failed: `%s`"), \
- BFS_DIAG_ARGS_(__VA_ARGS__))
+#define bfs_check_(str, ...) \
+ BFS_VA_IF(__VA_ARGS__) \
+ (bfs_diag(__VA_ARGS__)) \
+ (bfs_diag("Check failed: `%s`", str))
/**
* Check a condition, logging the current error string on failure.
*/
-#define bfs_echeck(...) \
- bfs_echeck_(#__VA_ARGS__, __VA_ARGS__, "", )
-
-#define bfs_echeck_(str, cond, format, ...) \
- bfs_check_impl((cond) || (bfs_echeck__(format, BFS_DIAG_MSG_(format, str), __VA_ARGS__), false))
+#define bfs_echeck(cond, ...) \
+ bfs_check_impl((cond) || (bfs_echeck_(#cond, __VA_ARGS__), false))
-#define bfs_echeck__(format, ...) \
- bfs_diagf(sizeof(format) > 1 \
- ? BFS_DIAG_FORMAT_("%s" format "%s: %s") \
- : BFS_DIAG_FORMAT_("Check failed: `%s`: %s"), \
- BFS_DIAG_ARGS_(__VA_ARGS__ errstr(), ))
+#define bfs_echeck_(str, ...) \
+ BFS_VA_IF(__VA_ARGS__) \
+ (bfs_ediag(__VA_ARGS__)) \
+ (bfs_ediag("Check failed: `%s`", str))
#endif // BFS_TESTS_H