diff options
author | vincent-richard <[email protected]> | 2020-06-16 17:47:33 +0000 |
---|---|---|
committer | vincent-richard <[email protected]> | 2020-06-16 17:47:33 +0000 |
commit | 5c00f7867a9ad281025d07755a86121aaaf22242 (patch) | |
tree | b63a878f34d62ecef96259e9e0a370fd1ef5bd8c /tests | |
parent | Added test. (diff) | |
download | vmime-5c00f7867a9ad281025d07755a86121aaaf22242.tar.gz vmime-5c00f7867a9ad281025d07755a86121aaaf22242.zip |
#238 Fixed whitespace between encoded words
Diffstat (limited to 'tests')
-rw-r--r-- | tests/parser/textTest.cpp | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/tests/parser/textTest.cpp b/tests/parser/textTest.cpp index 16abf11b..e9ddc262 100644 --- a/tests/parser/textTest.cpp +++ b/tests/parser/textTest.cpp @@ -59,6 +59,7 @@ VMIME_TEST_SUITE_BEGIN(textTest) VMIME_TEST(testInternationalizedEmail_UTF8) VMIME_TEST(testInternationalizedEmail_nonUTF8) VMIME_TEST(testInternationalizedEmail_folding) + VMIME_TEST(testInternationalizedEmail_whitespace) VMIME_TEST(testWronglyPaddedB64Words) VMIME_TEST(testFixBrokenWords) @@ -694,6 +695,90 @@ VMIME_TEST_SUITE_BEGIN(textTest) ); } + void testInternationalizedEmail_whitespace() { + + // Sanity checks for running this test + { + vmime::text t; + t.parse("=?utf-8?Q?Adquisi=C3=B3n?= de Laptop y celular"); + + VASSERT_EQ("parse", "Adquisión de Laptop y celular", t.getWholeBuffer()); + } + + { + vmime::text t("Adquisi\xc3\xb3n de Laptop y celular", vmime::charset("UTF-8")); + + VASSERT_EQ("generate", "=?UTF-8?Q?Adquisi=C3=B3n?= de Laptop y celular", t.generate()); + } + + // Ensure a whitespace is added between encoded words in intl email support enabled + { + vmime::text t; + t.parse("=?utf-8?Q?Adquisi=C3=B3n?= de Laptop y celular"); + + std::ostringstream oss; + vmime::utility::outputStreamAdapter ossAdapter(oss); + vmime::generationContext gctx(vmime::generationContext::getDefaultContext()); + gctx.setInternationalizedEmailSupport(true); + t.generate(gctx, ossAdapter); + + VASSERT_EQ("generate", "Adquisi\xc3\xb3n de Laptop y celular", oss.str()); + } + + { + vmime::text t; + t.parse("=?utf-8?Q?Adquisi=C3=B3n?= de Laptop =?utf-8?Q?y?= celular"); + + std::ostringstream oss; + vmime::utility::outputStreamAdapter ossAdapter(oss); + vmime::generationContext gctx(vmime::generationContext::getDefaultContext()); + gctx.setInternationalizedEmailSupport(true); + t.generate(gctx, ossAdapter); + + VASSERT_EQ("generate", "Adquisi\xc3\xb3n de Laptop y celular", oss.str()); + } + + { + vmime::text t; + t.parse("=?utf-8?Q?Adquisi=C3=B3n?= de Laptop =?utf-8?Q?y_celular?="); + + std::ostringstream oss; + vmime::utility::outputStreamAdapter ossAdapter(oss); + vmime::generationContext gctx(vmime::generationContext::getDefaultContext()); + gctx.setInternationalizedEmailSupport(true); + t.generate(gctx, ossAdapter); + + VASSERT_EQ("generate", "Adquisi\xc3\xb3n de Laptop y celular", oss.str()); + } + + // Ensure no whitespace is added with non-encoded words + { + vmime::text t; + t.parse("Laptop y celular"); + + std::ostringstream oss; + vmime::utility::outputStreamAdapter ossAdapter(oss); + vmime::generationContext gctx(vmime::generationContext::getDefaultContext()); + gctx.setInternationalizedEmailSupport(true); + t.generate(gctx, ossAdapter); + + VASSERT_EQ("generate", "Laptop y celular", oss.str()); + } + + { + vmime::text t; + t.parse("=?utf-8?Q?Laptop_y_celular?="); + + std::ostringstream oss; + vmime::utility::outputStreamAdapter ossAdapter(oss); + vmime::generationContext gctx(vmime::generationContext::getDefaultContext()); + gctx.setInternationalizedEmailSupport(true); + t.generate(gctx, ossAdapter); + + VASSERT_EQ("generate", "Laptop y celular", oss.str()); + } + } + void testWronglyPaddedB64Words() { vmime::text outText; |