dovecot-2.2: lib-mail: test-message-header-decoder unit test fixed

dovecot at dovecot.org dovecot at dovecot.org
Sun May 11 19:32:56 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/71f168f3b7e6
changeset: 17371:71f168f3b7e6
user:      Timo Sirainen <tss at iki.fi>
date:      Sun May 11 22:32:19 2014 +0300
description:
lib-mail: test-message-header-decoder unit test fixed

diffstat:

 src/lib-mail/test-message-header-decode.c |  17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diffs (37 lines):

diff -r 3db2d96381ca -r 71f168f3b7e6 src/lib-mail/test-message-header-decode.c
--- a/src/lib-mail/test-message-header-decode.c	Sun May 11 22:31:54 2014 +0300
+++ b/src/lib-mail/test-message-header-decode.c	Sun May 11 22:32:19 2014 +0300
@@ -59,19 +59,30 @@
 
 	test_begin("message header encode & decode randomly");
 
-	buf[0] = 'x';
 	encoded = t_str_new(256);
 	decoded = t_str_new(256);
 	for (i = 0; i < 1000; i++) {
 		/* fill only with 7bit data so we don't have to worry about
 		   the data being valid UTF-8 */
-		for (j = 1; j < sizeof(buf); j++)
+		for (j = 0; j < sizeof(buf); j++)
 			buf[j] = rand() % 128;
 		buflen = rand() % sizeof(buf);
 
 		str_truncate(encoded, 0);
 		str_truncate(decoded, 0);
-		message_header_encode_data(buf, buflen, encoded);
+
+		/* test Q */
+		message_header_encode_q(buf, buflen, encoded, 0);
+		message_header_decode_utf8(encoded->data, encoded->used,
+					   decoded, NULL);
+		test_assert(decoded->used == buflen &&
+			    memcmp(decoded->data, buf, buflen) == 0);
+
+		/* test B */
+		str_truncate(encoded, 0);
+		str_truncate(decoded, 0);
+
+		message_header_encode_b(buf, buflen, encoded, 0);
 		message_header_decode_utf8(encoded->data, encoded->used,
 					   decoded, NULL);
 		test_assert(decoded->used == buflen &&


More information about the dovecot-cvs mailing list