summaryrefslogtreecommitdiffstats
path: root/tests/tests.h
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2024-05-17 13:13:06 -0400
committerTavian Barnes <tavianator@tavianator.com>2024-05-17 13:57:01 -0400
commitc70e7375b1808b23fe4db2018d5e8c9bcb70464d (patch)
treeb84fca909d89c7d5a7f461c7cafeae0058bdca79 /tests/tests.h
parentc3d6f07b8e4d22df533ce7a90660ae1da2df5476 (diff)
downloadbfs-c70e7375b1808b23fe4db2018d5e8c9bcb70464d.tar.xz
diag: New helpers to include xstrerror(errno) automatically
Diffstat (limited to 'tests/tests.h')
-rw-r--r--tests/tests.h15
1 files changed, 6 insertions, 9 deletions
diff --git a/tests/tests.h b/tests/tests.h
index d26a5a0..19b7f5e 100644
--- a/tests/tests.h
+++ b/tests/tests.h
@@ -57,20 +57,17 @@ static inline bool bfs_check(bool ret) {
: "Check failed: `%s`%s", \
str, __VA_ARGS__), false))
-/** Get a string description of the last error. */
-const char *bfs_errstr(void);
-
/**
* Check a condition, logging the current error string on failure.
*/
-#define bfs_pcheck(...) \
- bfs_pcheck_(#__VA_ARGS__, __VA_ARGS__, "", "")
+#define bfs_echeck(...) \
+ bfs_echeck_(#__VA_ARGS__, __VA_ARGS__, "", bfs_errstr())
-#define bfs_pcheck_(str, cond, format, ...) \
+#define bfs_echeck_(str, cond, format, ...) \
((cond) ? true : (bfs_diag( \
sizeof(format) > 1 \
- ? "%.0s" format "%s%s: %s" \
- : "Check failed: `%s`%s: %s", \
- str, __VA_ARGS__, bfs_errstr()), false))
+ ? "%.0s" format "%s: %s" \
+ : "Check failed: `%s`: %s", \
+ str, __VA_ARGS__), false))
#endif // BFS_TESTS_H