From ec715e6058ffb6b4820a2511b35db53ac7a2e858 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Thu, 5 Apr 2012 22:29:32 +0200 Subject: [PATCH] Added tests for Quoted-Printable encoding. --- tests/utility/encoderTest.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/utility/encoderTest.cpp b/tests/utility/encoderTest.cpp index f2d42b66..b2d6bc8e 100644 --- a/tests/utility/encoderTest.cpp +++ b/tests/utility/encoderTest.cpp @@ -33,6 +33,8 @@ VMIME_TEST_SUITE_BEGIN VMIME_TEST_LIST_BEGIN VMIME_TEST(testBase64) VMIME_TEST(testQuotedPrintable) + VMIME_TEST(testQuotedPrintable_SoftLineBreaks) + VMIME_TEST(testQuotedPrintable_CRLF) VMIME_TEST(testQuotedPrintable_RFC2047) VMIME_TEST_LIST_END @@ -288,6 +290,35 @@ VMIME_TEST_SUITE_BEGIN } } + /** Tests Soft Line Breaks (RFC-2047/6.7(5). */ + void testQuotedPrintable_SoftLineBreaks() + { + VASSERT_EQ("1", "Now's the time=\r\n" + " for all folk =\r\n" + "to come to the=\r\n" + " aid of their =\r\n" + "country.", + encode("quoted-printable", "Now's the time for all folk " + "to come to the aid of their country.", 15)); + } + + /** In text mode, ensure line breaks in QP-encoded text are represented + * by a CRLF sequence, as per RFC-2047/6.7(4). */ + void testQuotedPrintable_CRLF() + { + vmime::propertySet encProps; + + // in "text" mode + encProps["text"] = true; + VASSERT_EQ("text", "line1\r\nline2", + encode("quoted-printable", "line1\r\nline2", 80, encProps)); + + // in "binary" mode + encProps["text"] = false; + VASSERT_EQ("binary", "line1=0D=0Aline2", + encode("quoted-printable", "line1\r\nline2", 80, encProps)); + } + void testQuotedPrintable_RFC2047() { /*