diff options
author | Vincent Richard <[email protected]> | 2006-10-02 13:44:00 +0000 |
---|---|---|
committer | Vincent Richard <[email protected]> | 2006-10-02 13:44:00 +0000 |
commit | b79a6ad89013e4aba947df043ad26cbe7fbab5a5 (patch) | |
tree | 352ecfc74b409c71f68e906630940bda71350083 /tests/parser/textTest.cpp | |
parent | Attachment [file]name. (diff) | |
download | vmime-b79a6ad89013e4aba947df043ad26cbe7fbab5a5.tar.gz vmime-b79a6ad89013e4aba947df043ad26cbe7fbab5a5.zip |
Fixed bug #1096610: non-integral number of chars in RFC-2047 encoded words.
Diffstat (limited to 'tests/parser/textTest.cpp')
-rw-r--r-- | tests/parser/textTest.cpp | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/tests/parser/textTest.cpp b/tests/parser/textTest.cpp index 011ec294..adcd014a 100644 --- a/tests/parser/textTest.cpp +++ b/tests/parser/textTest.cpp @@ -41,9 +41,34 @@ VMIME_TEST_SUITE_BEGIN VMIME_TEST(testWordConstructors) VMIME_TEST(testWordParse) VMIME_TEST(testWordGenerate) + 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; + } + + static const vmime::string cleanGeneratedWords(const std::string& str) + { + std::istringstream iss(str); + + std::string res; + std::string x; + + while (std::getline(iss, x)) + res += vmime::utility::stringUtils::trim(x); + + return res; + } + + void testConstructors() { vmime::text t1; @@ -171,16 +196,6 @@ VMIME_TEST_SUITE_BEGIN // TODO } - 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; - } - void testDisplayForm() { #define DISPLAY_FORM(x) getDisplayText(*vmime::text::decodeAndUnfold(x)) @@ -254,5 +269,15 @@ VMIME_TEST_SUITE_BEGIN vmime::word("\xf1\xf2\xf3\xf4\xf5", vmime::charset("foo")).generate()); } + void testWordGenerateMultiBytes() + { + // Ensure we don't encode a non-integral number of characters + VASSERT_EQ("1", "=?utf-8?Q?aaa?==?utf-8?Q?=C3=A9?==?utf-8?Q?zzz?=", + cleanGeneratedWords(vmime::word("aaa\xc3\xa9zzz", vmime::charset("utf-8")).generate(16))); + + VASSERT_EQ("1", "=?utf-8?Q?aaa=C3=A9?==?utf-8?Q?zzz?=", + cleanGeneratedWords(vmime::word("aaa\xc3\xa9zzz", vmime::charset("utf-8")).generate(17))); + } + VMIME_TEST_SUITE_END |