From: Michael Tremer Date: Tue, 2 Mar 2021 11:42:05 +0000 (+0000) Subject: tests: Check and warn if an expected string is NULL X-Git-Tag: 0.9.28~1285^2~666 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=05035906ef8abe834804984a71622f7fab75ee88;p=pakfire.git tests: Check and warn if an expected string is NULL Signed-off-by: Michael Tremer --- diff --git a/tests/testsuite.h b/tests/testsuite.h index cbd10df30..4b180c074 100644 --- a/tests/testsuite.h +++ b/tests/testsuite.h @@ -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)