From d825624d92fcd303556d65e9cfbcc2635570a19b Mon Sep 17 00:00:00 2001 From: Snild Dolkow Date: Mon, 4 Sep 2023 16:02:45 +0200 Subject: [PATCH] minicheck: Add fail_unless() macro ...and fix _fail_unless() so that it doesn't always fail. All existing calls to it pass 0, so there's no immediate change in behavior in this commit. --- expat/tests/minicheck.c | 4 +++- expat/tests/minicheck.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/expat/tests/minicheck.c b/expat/tests/minicheck.c index 45d6afe6..0eee72a3 100644 --- a/expat/tests/minicheck.c +++ b/expat/tests/minicheck.c @@ -244,7 +244,9 @@ _fail_unless(int condition, const char *file, int line, const char *msg) { we have a failure, so there's no reason to be quiet about what it is. */ - UNUSED_P(condition); + if (condition) { + return; + } _check_current_filename = file; _check_current_lineno = line; if (msg != NULL) { diff --git a/expat/tests/minicheck.h b/expat/tests/minicheck.h index 28e1a60d..c3a44cdb 100644 --- a/expat/tests/minicheck.h +++ b/expat/tests/minicheck.h @@ -84,6 +84,8 @@ extern "C" { void PRINTF_LIKE(1, 2) set_subtest(char const *fmt, ...); # define fail(msg) _fail_unless(0, __FILE__, __LINE__, msg) +# define fail_unless(cond) \ + _fail_unless((cond), __FILE__, __LINE__, "check failed: " #cond) typedef void (*tcase_setup_function)(void); typedef void (*tcase_teardown_function)(void);