diff options
author | Vincent Richard <[email protected]> | 2008-04-28 19:49:48 +0000 |
---|---|---|
committer | Vincent Richard <[email protected]> | 2008-04-28 19:49:48 +0000 |
commit | 439b2b3e90cb78a81e8d42ffdcd8543c64b1d1de (patch) | |
tree | a51cb6e1f77bb6f2f6a7c1d4c14df290bf7370b7 /tests/parser/textTest.cpp | |
parent | Removed old GNU TLS error. (diff) | |
download | vmime-439b2b3e90cb78a81e8d42ffdcd8543c64b1d1de.tar.gz vmime-439b2b3e90cb78a81e8d42ffdcd8543c64b1d1de.zip |
Fixed extra space in subject (see https://sourceforge.net/forum/message.php?msg_id=4894970).
Diffstat (limited to 'tests/parser/textTest.cpp')
-rw-r--r-- | tests/parser/textTest.cpp | 52 |
1 files changed, 43 insertions, 9 deletions
diff --git a/tests/parser/textTest.cpp b/tests/parser/textTest.cpp index 706452fb..152dbc46 100644 --- a/tests/parser/textTest.cpp +++ b/tests/parser/textTest.cpp @@ -42,18 +42,14 @@ VMIME_TEST_SUITE_BEGIN VMIME_TEST(testWordParse) VMIME_TEST(testWordGenerate) VMIME_TEST(testWordGenerateSpace) + VMIME_TEST(testWordGenerateSpace2) VMIME_TEST(testWordGenerateMultiBytes) VMIME_TEST_LIST_END static const vmime::string getDisplayText(const vmime::text& t) { - vmime::string res; - - for (int i = 0 ; i < t.getWordCount() ; ++i) - res += t.getWordAt(i)->getBuffer(); - - return res; + return t.getWholeBuffer(); } static const vmime::string cleanGeneratedWords(const std::string& str) @@ -142,11 +138,11 @@ VMIME_TEST_SUITE_BEGIN t2.createFromString(s2, c2); VASSERT_EQ("2.1", 3, t2.getWordCount()); - VASSERT_EQ("2.2", s2_1, t2.getWordAt(0)->getBuffer()); + VASSERT_EQ("2.2", "some ASCII characters and special chars:", t2.getWordAt(0)->getBuffer()); VASSERT_EQ("2.3", vmime::charset(vmime::charsets::US_ASCII), t2.getWordAt(0)->getCharset()); - VASSERT_EQ("2.4", s2_2, t2.getWordAt(1)->getBuffer()); + VASSERT_EQ("2.4", "\xf1\xf2\xf3\xf4", t2.getWordAt(1)->getBuffer()); VASSERT_EQ("2.5", c2, t2.getWordAt(1)->getCharset()); - VASSERT_EQ("2.6", s2_3, t2.getWordAt(2)->getBuffer()); + VASSERT_EQ("2.6", "and then more ASCII chars.", t2.getWordAt(2)->getBuffer()); VASSERT_EQ("2.7", vmime::charset(vmime::charsets::US_ASCII), t2.getWordAt(2)->getCharset()); } @@ -215,6 +211,15 @@ VMIME_TEST_SUITE_BEGIN VASSERT_EQ("9", "a b ", DISPLAY_FORM(" \t =?ISO-8859-1?Q?a?= b ")); VASSERT_EQ("10", "a b", DISPLAY_FORM(" a\r\n\t b")); + VASSERT_EQ("11", "a b c", DISPLAY_FORM("a =?ISO-8859-1?Q?b?= c")); + VASSERT_EQ("12", "a b c ", DISPLAY_FORM("a =?ISO-8859-1?Q?b?= c ")); + VASSERT_EQ("13", "a b c ", DISPLAY_FORM(" a =?ISO-8859-1?Q?b?= c ")); + VASSERT_EQ("14", "a b c d", DISPLAY_FORM("a =?ISO-8859-1?Q?b?= c =?ISO-8859-1?Q?d?= ")); + VASSERT_EQ("15", "a b c d e", DISPLAY_FORM("a =?ISO-8859-1?Q?b?= c =?ISO-8859-1?Q?d?= e")); + + // Whitespaces and multiline + VASSERT_EQ("16", "a b c d e", DISPLAY_FORM("=?ISO-8859-1?Q?a_b_?=c\n\t=?ISO-8859-1?Q?d_?=e")); + #undef DISPLAY_FORM } @@ -293,6 +298,35 @@ VMIME_TEST_SUITE_BEGIN txt2.parse(encoded, 0, encoded.length()); VASSERT_EQ("3", decoded, txt2.getWholeBuffer()); + + // -- test rencoding + VASSERT_EQ("4", encoded, txt2.generate()); + } + + void testWordGenerateSpace2() + { + // White-space between two encoded words (#2) + vmime::text txt; + txt.appendWord(vmime::create <vmime::word>("Facture ", "utf-8")); + txt.appendWord(vmime::create <vmime::word>("\xc3\xa0", "utf-8")); + txt.appendWord(vmime::create <vmime::word>(" envoyer ", "utf-8")); + txt.appendWord(vmime::create <vmime::word>("\xc3\xa0", "utf-8")); + txt.appendWord(vmime::create <vmime::word>(" Martine", "utf-8")); + + const vmime::string decoded = "Facture ""\xc3\xa0"" envoyer ""\xc3\xa0"" Martine"; + const vmime::string encoded = "Facture =?utf-8?B?w6A=?= envoyer =?utf-8?B?w6A=?= Martine"; + + // -- test encoding + VASSERT_EQ("1", encoded, txt.generate()); + + // -- ensure no space is added when decoding + vmime::text txt2; + txt2.parse(encoded, 0, encoded.length()); + + VASSERT_EQ("2", decoded, txt2.getWholeBuffer()); + + // -- test rencoding + VASSERT_EQ("3", encoded, txt2.generate()); } void testWordGenerateMultiBytes() |