]> 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)
committerGitLab <gitlab@git.dovecot.net>
Mon, 30 Jan 2017 16:00:26 +0000 (18:00 +0200)
Actually show the parse error.

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

index 27751d7e9fdb3b2345e4396d25adc95b5cbd285a..5ca709ebddfcdb7e1d925f231f6b5b3932c80288 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();