dovecot-2.2: lib-charset: Updated test-charset unit test to chec...
dovecot at dovecot.org
dovecot at dovecot.org
Mon Sep 7 21:35:18 UTC 2015
details: http://hg.dovecot.org/dovecot-2.2/rev/93991734ae75
changeset: 19119:93991734ae75
user: Timo Sirainen <tss at iki.fi>
date: Tue Sep 08 00:33:21 2015 +0300
description:
lib-charset: Updated test-charset unit test to check for iconv() E2BIG result
diffstat:
src/lib-charset/test-charset.c | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diffs (31 lines):
diff -r f600285c3df2 -r 93991734ae75 src/lib-charset/test-charset.c
--- a/src/lib-charset/test-charset.c Tue Sep 08 00:07:55 2015 +0300
+++ b/src/lib-charset/test-charset.c Tue Sep 08 00:33:21 2015 +0300
@@ -25,7 +25,7 @@
{ "p\xC3\xA4\xC3", "p\xC3\xA4", CHARSET_RET_INCOMPLETE_INPUT },
{ "p\xC3\xA4\xC3""a", "p\xC3\xA4"UNICODE_REPLACEMENT_CHAR_UTF8"a", CHARSET_RET_INVALID_INPUT }
};
- string_t *str = t_str_new(128);
+ string_t *src, *str = t_str_new(256);
enum charset_result result;
unsigned int i;
@@ -36,6 +36,18 @@
test_assert_idx(strcmp(tests[i].output, str_c(str)) == 0, i);
test_assert_idx(result == tests[i].result, i);
}
+ /* check that E2BIG handling works. We assume that iconv() is called
+ with 8192 byte buffer (tmpbuf[8192]) */
+ src = str_new(default_pool, 16384);
+ for (i = 0; i < 8190; i++)
+ str_append_c(src, 'a' + i % ('z'-'a'+1));
+ for (i = 0; i < 256; i++) {
+ str_truncate(str, 0);
+ str_append_c(src, 'A' + i % ('Z'-'A'+1));
+ test_assert_idx(charset_to_utf8_str(input_charset, NULL,
+ str_c(src), str, &result) == 0, i);
+ }
+ str_free(&src);
}
static void test_charset_utf8(void)
More information about the dovecot-cvs
mailing list