]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-imap: test-imap-bodystructure: Improved handing of parse errors.
authorStephan Bosch <stephan.bosch@dovecot.fi>
Mon, 9 Jan 2017 15:20:29 +0000 (16:20 +0100)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 20 Feb 2017 09:24:51 +0000 (11:24 +0200)
Actually show the parse error.

src/lib-imap/test-imap-bodystructure.c

index c84dd63e8ca48c099442ea014e805a1e9b146b22..ba90132eab5a13c15f9ba1a3eb99518d7d82f793 100644 (file)
@@ -128,6 +128,7 @@ static void test_imap_bodystructure_parse(void)
        struct message_part *parts;
        const char *error;
        unsigned int i;
+       int ret;
 
        for (i = 0; i < parse_tests_count; i++) T_BEGIN {
                struct parse_test *test = &parse_tests[i];
@@ -141,12 +142,17 @@ static void test_imap_bodystructure_parse(void)
                                                                     str, &error) == 0);
                test_assert(strcmp(str_c(str), test->body) == 0);
 
-               test_assert(imap_bodystructure_parse(test->bodystructure,
-                                            pool, parts, &error) == 0);
+               ret = imap_bodystructure_parse(test->bodystructure,
+                                                          pool, parts, &error);
+               test_assert(ret == 0);
 
-               str_truncate(str, 0);
-               imap_bodystructure_write(parts, str, TRUE);
-               test_assert(strcmp(str_c(str), test->bodystructure) == 0);
+               if (ret == 0) {
+                       str_truncate(str, 0);
+                       imap_bodystructure_write(parts, str, TRUE);
+                       test_assert(strcmp(str_c(str), test->bodystructure) == 0);
+               } else {
+                       i_error("Invalid BODYSTRUCTURE: %s", error);
+               }
 
                pool_unref(&pool);
                test_end();