]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-test: test-common - Make test_assert_strcmp() accept NULL parameters.
authorStephan Bosch <stephan.bosch@dovecot.fi>
Sat, 6 Jul 2019 14:31:05 +0000 (16:31 +0200)
committerStephan Bosch <stephan.bosch@dovecot.fi>
Tue, 9 Jul 2019 19:42:49 +0000 (21:42 +0200)
src/lib-test/test-common.c
src/lib-test/test-common.h

index f711713e2d1eb696fab5ea55383c82519012bf9b..781dbbc67c32ac09463954cfc7b663db509ffbb2 100644 (file)
@@ -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;
 }
index 0c84fab40d3c8b8bb1d310007012d9a640ebfbe3..96a814969fabdd85e1a08283a36717aa174cb7da 100644 (file)
@@ -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);