]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-mail: test-message-address - Test also writing invalid addresses
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 7 Jun 2017 09:33:10 +0000 (12:33 +0300)
committerGitLab <gitlab@git.dovecot.net>
Wed, 7 Jun 2017 15:33:55 +0000 (18:33 +0300)
src/lib-mail/test-message-address.c

index aa6e5fab8aecfedf1c47997830832b42cece68b1..897ce6b71f55da4a7fbe507ba04cb592b7261a79 100644 (file)
@@ -38,11 +38,11 @@ static void test_message_address(void)
                  { NULL, NULL, "@route,@route2", "user", "domain", FALSE } },
                { "hello <@route ,@route2:user@domain>", "hello <@route,@route2:user@domain>",
                  { NULL, "hello", "@route,@route2", "user", "domain", FALSE } },
-               { "hello", NULL,
+               { "hello", "hello <@>",
                  { NULL, "hello", NULL, "", "", TRUE } },
-               { "user (hello)", NULL,
+               { "user (hello)", "hello <user@>",
                  { NULL, "hello", NULL, "user", "", TRUE } },
-               { "hello <user>", NULL,
+               { "hello <user>", "hello <user@>",
                  { NULL, "hello", NULL, "user", "", TRUE } },
                { "@domain", NULL,
                  { NULL, NULL, NULL, "", "domain", TRUE } },
@@ -72,12 +72,12 @@ static void test_message_address(void)
                test_assert_idx(addr != NULL && addr->next == NULL &&
                                cmp_addr(addr, &test->addr), i);
 
+               str_truncate(str, 0);
+               message_address_write(str, addr);
+               wanted_string = test->wanted_output != NULL ?
+                       test->wanted_output : test->input;
+               test_assert_idx(strcmp(str_c(str), wanted_string) == 0, i);
                if (!test->addr.invalid_syntax) {
-                       str_truncate(str, 0);
-                       message_address_write(str, addr);
-                       wanted_string = test->wanted_output != NULL ?
-                               test->wanted_output : test->input;
-                       test_assert_idx(strcmp(str_c(str), wanted_string) == 0, i);
                        if (i != 0) {
                                if ((i % 2) == 0)
                                        str_append(group, ",");