]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
various - remove 8-bit characters from literal strings in test cases
authorPhil Carmody <phil@dovecot.fi>
Mon, 16 Nov 2015 10:29:51 +0000 (12:29 +0200)
committerPhil Carmody <phil@dovecot.fi>
Mon, 16 Nov 2015 10:29:51 +0000 (12:29 +0200)
C has a portable way of expressing characters not in the basic character
set, namely \xNN escaping. Otherwise, the interpretation of the raw utf-8
is implentation dependent. This has the benefit of making some tests'
expected output more obvious, such as "=c3=a4" matching "\xC3\xA4", even
if it hinders the readability of some natural-language-based tests.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
src/lib-charset/test-charset.c
src/lib-fts/test-fts-filter.c
src/lib-fts/test-fts-tokenizer.c
src/lib-imap/test-imap-utf7.c
src/lib-mail/test-istream-qp-decoder.c
src/lib-mail/test-message-header-decode.c
src/lib-mail/test-message-header-encode.c

index daf4227d94b7770ccf2e6a650f073769390a37ff..b82539375fbab833f117e4a73b1160c9fd9cf8b9 100644 (file)
@@ -66,9 +66,13 @@ static void test_charset_iconv(void)
                const char *output;
                enum charset_result result;
        } tests[] = {
-               { "ISO-8859-1", "p\xE4\xE4", "pää", CHARSET_RET_OK },
+               { "ISO-8859-1", "p\xE4\xE4", "p\xC3\xA4\xC3\xA4", CHARSET_RET_OK },
                { "UTF-7", "+AOQA5AD2AOQA9gDkAPYA5AD2AOQA9gDkAPYA5AD2AOQA9gDkAPYA5AD2AOQA9gDkAPYA5AD2AOQA9gDkAPYA5AD2AOQA9gDk",
-                 "ääöäöäöäöäöäöäöäöäöäöäöäöäöäöäöäöäöä", CHARSET_RET_OK }
+                 "\xC3\xA4\xC3\xA4\xC3\xB6\xC3\xA4\xC3\xB6\xC3\xA4\xC3\xB6\xC3\xA4"
+                 "\xC3\xB6\xC3\xA4\xC3\xB6\xC3\xA4\xC3\xB6\xC3\xA4\xC3\xB6\xC3\xA4"
+                 "\xC3\xB6\xC3\xA4\xC3\xB6\xC3\xA4\xC3\xB6\xC3\xA4\xC3\xB6\xC3\xA4"
+                 "\xC3\xB6\xC3\xA4\xC3\xB6\xC3\xA4\xC3\xB6\xC3\xA4\xC3\xB6\xC3\xA4"
+                 "\xC3\xB6\xC3\xA4\xC3\xB6\xC3\xA4", CHARSET_RET_OK }
        };
        string_t *str = t_str_new(128);
        struct charset_translation *trans;
index 4955c73dd733594beb694e97943949c9dde188e7..4f6a2cf73770c20a2ccc1144cb27af090ee49097 100644 (file)
@@ -415,8 +415,8 @@ static void test_fts_filter_normalizer_swedish_short(void)
        struct fts_filter *norm = NULL;
        const char *input[] = {
                "Vem",
-               "Å",
-               "ÅÄÖ",
+               "\xC3\x85",
+               "\xC3\x85\xC3\x84\xC3\x96",
                "Vem kan segla f\xC3\xB6rutan vind?\n"
                "\xC3\x85\xC3\x84\xC3\x96\xC3\xB6\xC3\xA4\xC3\xA5"
        };
@@ -450,8 +450,8 @@ static void test_fts_filter_normalizer_swedish_short_default_id(void)
        struct fts_filter *norm = NULL;
        const char *input[] = {
                "Vem",
-               "Å",
-               "ÅÄÖ",
+               "\xC3\x85",
+               "\xC3\x85\xC3\x84\xC3\x96",
                "Vem kan segla f\xC3\xB6rutan vind?\n"
                "\xC3\x85\xC3\x84\xC3\x96\xC3\xB6\xC3\xA4\xC3\xA5"
        };
@@ -662,14 +662,14 @@ static void test_fts_filter_english_possessive(void)
                "foo'",
 
                "foo's",
-               "fooä's",
+               "foo\xC3\xA4's",
                "foo'S",
                "foos'S",
                "foo's's",
                "foo'ss",
 
                "foo\xE2\x80\x99s",
-               "fooä\xE2\x80\x99s",
+               "foo\xC3\xA4\xE2\x80\x99s",
                "foo\xE2\x80\x99S",
                "foos\xE2\x80\x99S",
                "foo\xE2\x80\x99s\xE2\x80\x99s",
@@ -679,14 +679,14 @@ static void test_fts_filter_english_possessive(void)
                "foo'",
 
                "foo",
-               "fooä",
+               "foo\xC3\xA4",
                "foo",
                "foos",
                "foo's",
                "foo'ss",
 
                "foo",
-               "fooä",
+               "foo\xC3\xA4",
                "foo",
                "foos",
                "foo\xE2\x80\x99s",
index d861e85c765d910b6a326fedf6c8fb4048c1260d..643acd77dc0876d81c4c030cdc182f90b63239b7 100644 (file)
@@ -20,9 +20,9 @@ static const char *test_inputs[] = {
        "abc@example.com, "
        "Bar Baz <bar@example.org>, "
        "foo@domain "
-       "1234567890123456789012345678ä,"
-       "12345678901234567890123456789ä,"
-       "123456789012345678901234567890ä,"
+       "1234567890123456789012345678\xC3\xA4,"
+       "12345678901234567890123456789\xC3\xA4,"
+       "123456789012345678901234567890\xC3\xA4,"
        "and longlonglongabcdefghijklmnopqrstuvwxyz more.\n\n "
        "(\"Hello world\")3.14 3,14 last",
 
@@ -30,8 +30,8 @@ static const char *test_inputs[] = {
 
        "' ' '' ''' 'quoted text' 'word' 'hlo words' you're bad'''word '''pre post'''",
 
-       "'1234567890123456789012345678ä,"
-       "123456789012345678901234567x'ä,"
+       "'1234567890123456789012345678\xC3\xA4,"
+       "123456789012345678901234567x'\xC3\xA4,"
        "1234567890123456789012345678x're,"
        "1234567890123456789012345678x',"
        "1234567890123456789012345678x'',"
@@ -141,7 +141,7 @@ static void test_fts_tokenizer_generic_only(void)
                "there", "was", "text", "galor\xC3\xA9",
                "abc", "example", "com", "Bar", "Baz",
                "bar", "example", "org", "foo", "domain",
-               "1234567890123456789012345678ä",
+               "1234567890123456789012345678\xC3\xA4",
                "12345678901234567890123456789",
                "123456789012345678901234567890",
                "and", "longlonglongabcdefghijklmnopqr",
@@ -152,7 +152,7 @@ static void test_fts_tokenizer_generic_only(void)
                "quoted", "text", "word", "hlo", "words", "you're", "bad",
                "word", "pre", "post", NULL,
 
-               "1234567890123456789012345678ä",
+               "1234567890123456789012345678\xC3\xA4",
                "123456789012345678901234567x'",
                "1234567890123456789012345678x'",
                "1234567890123456789012345678x",
@@ -200,7 +200,7 @@ static void test_fts_tokenizer_generic_tr29_only(void)
                "there", "was", "text", "galor\xC3\xA9",
                "abc", "example", "com", "Bar", "Baz",
                "bar", "example", "org", "foo", "domain",
-               "1234567890123456789012345678ä",
+               "1234567890123456789012345678\xC3\xA4",
                "12345678901234567890123456789",
                "123456789012345678901234567890",
                "and", "longlonglongabcdefghijklmnopqr",
@@ -211,7 +211,7 @@ static void test_fts_tokenizer_generic_tr29_only(void)
                "quoted", "text", "word", "hlo", "words", "you're", "bad",
                "word", "pre", "post", NULL,
 
-               "1234567890123456789012345678ä",
+               "1234567890123456789012345678\xC3\xA4",
                "123456789012345678901234567x'",
                "1234567890123456789012345678x'",
                "1234567890123456789012345678x",
@@ -256,7 +256,7 @@ static void test_fts_tokenizer_generic_tr29_wb5a(void)
                "there", "was", "text", "galor\xC3\xA9",
                "abc", "example", "com", "Bar", "Baz",
                "bar", "example", "org", "foo", "domain",
-               "1234567890123456789012345678ä",
+               "1234567890123456789012345678\xC3\xA4",
                "12345678901234567890123456789",
                "123456789012345678901234567890",
                "and", "longlonglongabcdefghijklmnopqr",
@@ -267,7 +267,7 @@ static void test_fts_tokenizer_generic_tr29_wb5a(void)
                "quoted", "text", "word", "hlo", "words", "you're", "bad",
                "word", "pre", "post", NULL,
 
-               "1234567890123456789012345678ä",
+               "1234567890123456789012345678\xC3\xA4",
                "123456789012345678901234567x'",
                "1234567890123456789012345678x'",
                "1234567890123456789012345678x",
index efece73bd8c6a5f45732e7aa10a95dafc6967c0a..509a755558c0bb80cccdf3d8ca7905625d8f6af5 100644 (file)
@@ -13,8 +13,9 @@ static void test_imap_utf7_by_example(void)
                const char *mutf7;
        } tests[] = {
                { "&&x&&", "&-&-x&-&-" },
-               { "~peter/mail/台北/日本語", "~peter/mail/&U,BTFw-/&ZeVnLIqe-" },
-               { "tietäjä", "tiet&AOQ-j&AOQ-" },
+               { "~peter/mail/\xe5\x8f\xb0\xe5\x8c\x97/\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e",
+                 "~peter/mail/&U,BTFw-/&ZeVnLIqe-" },
+               { "tiet\xc3\xa4j\xc3\xa4", "tiet&AOQ-j&AOQ-" },
                { "p\xe4\xe4", NULL },
                { NULL, "&" },
                { NULL, "&Jjo" },
index c47a3d91b62270b2c4f8d4fd28a20fc03add3136..71ccd4eb3a26b3da3fa3b4b0ea19e27589bf4538 100644 (file)
@@ -10,15 +10,15 @@ static const struct {
        const char *output;
        int ret;
 } tests[] = {
-       { "p=C3=A4=C3=A4t=C3=B6s", "päätös", 0 },
-       { "p=c3=a4=c3=a4t=c3=b6s=  \n", "päätös", 0 },
-       { "p=c3=a4= \t \n=c3=\r\n=a4t=  \r\n=c3=b6s", "päätös", 0 },
+       { "p=C3=A4=C3=A4t=C3=B6s", "p\xC3\xA4\xC3\xA4t\xC3\xB6s", 0 },
+       { "p=c3=a4=c3=a4t=c3=b6s=  \n", "p\xC3\xA4\xC3\xA4t\xC3\xB6s", 0 },
+       { "p=c3=a4= \t \n=c3=\r\n=a4t=  \r\n=c3=b6s", "p\xC3\xA4\xC3\xA4t\xC3\xB6s", 0 },
 
-       { "p=c3=a4\rasdf", "pä", -1 },
+       { "p=c3=a4\rasdf", "p\xC3\xA4", -1 },
        { "p=c", "p", -1 },
        { "p=A", "p", -1 },
        { "p=Ax", "p", -1 },
-       { "p=c3=a4=c3=a4t=c3=b6s=  ", "päätös", -1 }
+       { "p=c3=a4=c3=a4t=c3=b6s=  ", "p\xC3\xA4\xC3\xA4t\xC3\xB6s", -1 }
 };
 
 static void
index 04898cd6d0640f169b035fe0cd2f0b9329de15d4..154b2967ac984a03c4e1418fb6afb303d521324f 100644 (file)
@@ -27,13 +27,13 @@ charset_to_utf8(struct charset_translation *t ATTR_UNUSED,
 static void test_message_header_decode(void)
 {
        static const char *data[] = {
-               " \t=?utf-8?q?=c3=a4?=  =?utf-8?q?=c3=a4?=  b  \t\r\n ", "ää  b  \t\r\n ",
-               "a =?utf-8?q?=c3=a4?= b", "a ä b",
-               "a =?utf-8?q?=c3=a4?= b", "a ä b",
-               "a =?utf-8?q?=c3=a4?=\t\t\r\n =?utf-8?q?=c3=a4?= b", "a ää b",
-               "a =?utf-8?q?=c3=a4?=  x  =?utf-8?q?=c3=a4?= b", "a ä  x  ä b",
-               "a =?utf-8?b?w6TDpCDDpA==?= b", "a ää ä b",
-               "=?utf-8?b?w6Qgw6Q=?=", "ä ä",
+               " \t=?utf-8?q?=c3=a4?=  =?utf-8?q?=c3=a4?=  b  \t\r\n ", "\xC3\xA4\xC3\xA4  b  \t\r\n ",
+               "a =?utf-8?q?=c3=a4?= b", "a \xC3\xA4 b",
+               "a =?utf-8?q?=c3=a4?= b", "a \xC3\xA4 b",
+               "a =?utf-8?q?=c3=a4?=\t\t\r\n =?utf-8?q?=c3=a4?= b", "a \xC3\xA4\xC3\xA4 b",
+               "a =?utf-8?q?=c3=a4?=  x  =?utf-8?q?=c3=a4?= b", "a \xC3\xA4  x  \xC3\xA4 b",
+               "a =?utf-8?b?w6TDpCDDpA==?= b", "a \xC3\xA4\xC3\xA4 \xC3\xA4 b",
+               "=?utf-8?b?w6Qgw6Q=?=", "\xC3\xA4 \xC3\xA4",
        };
        string_t *dest;
        unsigned int i;
index 70c80aff6f91054942d72e2b0e71120f940e72d9..a1f47be4380e7917df63f11bd085c30c5b06f332 100644 (file)
@@ -57,7 +57,7 @@ static void test_message_header_encode_q(void)
 
        str_append_c(input, 'a');
        for (i = 0; i < 40; i++)
-               str_append(input, "ä");
+               str_append(input, "\xC3\xA4");
        for (i = 0; i < 80; i++) {
                for (skip = 0; skip < 2; skip++) {
                        str_truncate(str, 0);
@@ -144,7 +144,7 @@ static void test_message_header_encode_b(void)
 
        str_append_c(input, 'a');
        for (i = 0; i < 40; i++)
-               str_append(input, "ä");
+               str_append(input, "\xC3\xA4");
        for (i = 0; i < 80; i++) {
                for (skip = 0; skip < 2; skip++) {
                        str_truncate(str, 0);
@@ -166,10 +166,10 @@ static void test_message_header_encode(void)
 {
        const char *data[] = {
                "a b", "a b",
-               "a bcäde f", "a =?utf-8?q?bc=C3=A4de?= f",
-               "a ää ä b", "a =?utf-8?b?w6TDpCDDpA==?= b",
-               "ä a ä", "=?utf-8?q?=C3=A4_a_=C3=A4?=",
-               "ää a ä", "=?utf-8?b?w6TDpCBhIMOk?=",
+               "a bc\xC3\xA4""de f", "a =?utf-8?q?bc=C3=A4de?= f",
+               "a \xC3\xA4\xC3\xA4 \xC3\xA4 b", "a =?utf-8?b?w6TDpCDDpA==?= b",
+               "\xC3\xA4 a \xC3\xA4", "=?utf-8?q?=C3=A4_a_=C3=A4?=",
+               "\xC3\xA4\xC3\xA4 a \xC3\xA4", "=?utf-8?b?w6TDpCBhIMOk?=",
                "=", "=",
                "?", "?",
                "a=?", "a=?",