From: Stephan Bosch Date: Sat, 6 Jul 2019 14:31:05 +0000 (+0200) Subject: lib-test: test-common - Make test_assert_strcmp() accept NULL parameters. X-Git-Tag: 2.3.9~396 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bf0f253473b25e7dc75118f46da4d2dedebd3a42;p=thirdparty%2Fdovecot%2Fcore.git lib-test: test-common - Make test_assert_strcmp() accept NULL parameters. --- diff --git a/src/lib-test/test-common.c b/src/lib-test/test-common.c index f711713e2d..781dbbc67c 100644 --- a/src/lib-test/test-common.c +++ b/src/lib-test/test-common.c @@ -56,7 +56,14 @@ void test_assert_failed_strcmp(const char *code, const char *file, unsigned int const char * src, const char * dst) { printf("%s: Assert(#%u) failed: %s\n", file, line, code); - printf(" \"%s\" != \"%s\"\n", src, dst); + if (src != NULL) + printf(" \"%s\" != ", src); + else + printf(" NULL != "); + if (dst != NULL) + printf("\"%s\"\n", dst); + else + printf("NULL\n"); fflush(stdout); test_success = FALSE; } diff --git a/src/lib-test/test-common.h b/src/lib-test/test-common.h index 0c84fab40d..96a814969f 100644 --- a/src/lib-test/test-common.h +++ b/src/lib-test/test-common.h @@ -29,7 +29,7 @@ void test_begin(const char *name); * in strcmp(). */ #define test_assert_strcmp(s1, s2) STMT_START { \ - if ((strcmp(s1,s2) != 0)) test_assert_failed_strcmp("strcmp(" #s1 "," #s2 ")", __FILE__, __LINE__, s1, s2); \ + if ((null_strcmp(s1,s2) != 0)) test_assert_failed_strcmp("strcmp(" #s1 "," #s2 ")", __FILE__, __LINE__, s1, s2); \ } STMT_END void test_assert_failed(const char *code, const char *file, unsigned int line);