changeset 21616:98ee758c138e

lib-imap: test-imap-bodystructure: Improved handing of parse errors. Actually show the parse error.
author Stephan Bosch <stephan.bosch@dovecot.fi>
date Mon, 09 Jan 2017 16:20:29 +0100
parents e2aa2a18fe16
children 6d5ed8b735b0
files src/lib-imap/test-imap-bodystructure.c
diffstat 1 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-imap/test-imap-bodystructure.c	Mon Jan 09 16:16:46 2017 +0100
+++ b/src/lib-imap/test-imap-bodystructure.c	Mon Jan 09 16:20:29 2017 +0100
@@ -128,6 +128,7 @@
 	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 @@
 								     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();