]> git.ipfire.org Git - pakfire.git/commitdiff
testsuite: Add simple true/false assertions
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 5 Oct 2021 13:38:58 +0000 (13:38 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 5 Oct 2021 13:38:58 +0000 (13:38 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
tests/libpakfire/util.c
tests/testsuite.h

index c36bb06ba91e2ec3d8f9704a888b270ae167925a..7dc5ffd0d1c25c8de03acbedcf399f8e15985e56 100644 (file)
@@ -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;
 
index f4e87cc0289b0bbfc31de172e305d85aa612f0aa..7cadd4a1c6be49075deb4b9679ea75e5fb197251 100644 (file)
@@ -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)) { \