]> git.ipfire.org Git - pakfire.git/commitdiff
tests: Check and warn if an expected string is NULL
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 2 Mar 2021 11:42:05 +0000 (11:42 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 2 Mar 2021 11:42:05 +0000 (11:42 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
tests/testsuite.h

index cbd10df303dfc171d3613f7f550296e90b446be1..4b180c0749ea2c0328cde29901f7fa15787c09f3 100644 (file)
@@ -63,11 +63,15 @@ int testsuite_run();
                } \
        } while (0)
 
-#define ASSERT_STRING_EQUALS(string, value) \
+#define ASSERT_STRING_EQUALS(value, string) \
        do { \
+               if (!value) { \
+                       LOG_ERROR("Failed assertion: Expected string " #value " (%s) is NULL\n", string); \
+                       return EXIT_FAILURE; \
+               } \
                if (strcmp(string, value) != 0) { \
-                       LOG_ERROR("Failed assertion: " #string " (%s) != " #value " %s:%d %s\n", \
-                               string, __FILE__, __LINE__, __PRETTY_FUNCTION__); \
+                       LOG_ERROR("Failed assertion: " #value " (%s) != " #string " %s:%d %s\n", \
+                               value, __FILE__, __LINE__, __PRETTY_FUNCTION__); \
                        return EXIT_FAILURE; \
                } \
        } while (0)