From: Michael Tremer Date: Tue, 5 Oct 2021 13:38:58 +0000 (+0000) Subject: testsuite: Add simple true/false assertions X-Git-Tag: 0.9.28~904 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa5c92a23f9597cbd2027835cae36f781f3a2c30;p=pakfire.git testsuite: Add simple true/false assertions Signed-off-by: Michael Tremer --- diff --git a/tests/libpakfire/util.c b/tests/libpakfire/util.c index c36bb06ba..7dc5ffd0d 100644 --- a/tests/libpakfire/util.c +++ b/tests/libpakfire/util.c @@ -54,8 +54,8 @@ FAIL: } static int test_string_startswith(const struct test* t) { - ASSERT_SUCCESS(pakfire_string_startswith("ABC", "A")); - ASSERT_FAILURE(pakfire_string_startswith("ABC", "B")); + ASSERT_TRUE(pakfire_string_startswith("ABC", "A")); + ASSERT_FALSE(pakfire_string_startswith("ABC", "B")); return EXIT_SUCCESS; diff --git a/tests/testsuite.h b/tests/testsuite.h index f4e87cc02..7cadd4a1c 100644 --- a/tests/testsuite.h +++ b/tests/testsuite.h @@ -91,6 +91,24 @@ int testsuite_run(); } \ } while (0) +#define ASSERT_TRUE(expr) \ + do { \ + if (!(expr)) { \ + LOG_ERROR("Failed assertion: " #expr " unexpectedly didn't return true in %s:%d: %m\n", \ + __FILE__, __LINE__, __PRETTY_FUNCTION__); \ + goto FAIL; \ + } \ + } while (0) + +#define ASSERT_FALSE(expr) \ + do { \ + if ((expr)) { \ + LOG_ERROR("Failed assertion: " #expr " unexpectedly didn't return false in %s:%d: %m\n", \ + __FILE__, __LINE__, __PRETTY_FUNCTION__); \ + goto FAIL; \ + } \ + } while (0) + #define ASSERT_ERRNO(expr, e) \ do { \ if (!(expr)) { \