aboutsummaryrefslogtreecommitdiffstats
path: root/tests/parser
diff options
context:
space:
mode:
Diffstat (limited to 'tests/parser')
-rw-r--r--tests/parser/attachmentHelperTest.cpp91
-rw-r--r--tests/parser/bodyPartTest.cpp81
-rw-r--r--tests/parser/bodyTest.cpp44
-rw-r--r--tests/parser/charsetFilteredOutputStreamTest.cpp38
-rw-r--r--tests/parser/charsetTest.cpp92
-rw-r--r--tests/parser/charsetTestSuites.hpp11
-rw-r--r--tests/parser/datetimeTest.cpp26
-rw-r--r--tests/parser/dispositionTest.cpp15
-rw-r--r--tests/parser/emailAddressTest.cpp127
-rw-r--r--tests/parser/emptyContentHandlerTest.cpp26
-rw-r--r--tests/parser/fileContentHandlerTest.cpp41
-rw-r--r--tests/parser/headerFieldTest.cpp38
-rw-r--r--tests/parser/headerTest.cpp97
-rw-r--r--tests/parser/htmlTextPartTest.cpp34
-rw-r--r--tests/parser/mailboxGroupTest.cpp18
-rw-r--r--tests/parser/mailboxListTest.cpp7
-rw-r--r--tests/parser/mailboxTest.cpp27
-rw-r--r--tests/parser/mediaTypeTest.cpp23
-rw-r--r--tests/parser/messageIdSequenceTest.cpp11
-rw-r--r--tests/parser/messageIdTest.cpp15
-rw-r--r--tests/parser/messageTest.cpp19
-rw-r--r--tests/parser/parameterTest.cpp335
-rw-r--r--tests/parser/pathTest.cpp15
-rw-r--r--tests/parser/streamContentHandlerTest.cpp59
-rw-r--r--tests/parser/stringContentHandlerTest.cpp82
-rw-r--r--tests/parser/textTest.cpp421
-rw-r--r--tests/parser/wordEncoderTest.cpp127
27 files changed, 1126 insertions, 794 deletions
diff --git a/tests/parser/attachmentHelperTest.cpp b/tests/parser/attachmentHelperTest.cpp
index 6bd3b7db..866f8de4 100644
--- a/tests/parser/attachmentHelperTest.cpp
+++ b/tests/parser/attachmentHelperTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -39,23 +39,25 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest)
VMIME_TEST_LIST_END
- static const vmime::string getStructure(const vmime::shared_ptr <vmime::bodyPart>& part)
- {
+ static const vmime::string getStructure(const vmime::shared_ptr <vmime::bodyPart>& part) {
+
vmime::shared_ptr <vmime::body> bdy = part->getBody();
vmime::string res = part->getBody()->getContentType().generate();
- if (bdy->getPartCount() == 0)
+ if (bdy->getPartCount() == 0) {
return res;
+ }
res += "[";
- for (size_t i = 0 ; i < bdy->getPartCount() ; ++i)
- {
+ for (size_t i = 0 ; i < bdy->getPartCount() ; ++i) {
+
vmime::shared_ptr <vmime::bodyPart> subPart = bdy->getPartAt(i);
- if (i != 0)
+ if (i != 0) {
res += ",";
+ }
res += getStructure(subPart);
}
@@ -63,8 +65,10 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest)
return res + "]";
}
- static const vmime::string extractBodyContents(const vmime::shared_ptr <const vmime::bodyPart>& part)
- {
+ static const vmime::string extractBodyContents(
+ const vmime::shared_ptr <const vmime::bodyPart>& part
+ ) {
+
vmime::shared_ptr <const vmime::contentHandler> cth = part->getBody()->getContents();
vmime::string data;
@@ -75,8 +79,8 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest)
return data;
}
- void testAddAttachment1()
- {
+ void testAddAttachment1() {
+
vmime::string data =
"Content-Type: text/plain\r\n"
"\r\n"
@@ -86,9 +90,11 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest)
vmime::shared_ptr <vmime::message> msg = vmime::make_shared <vmime::message>();
msg->parse(data);
- vmime::shared_ptr <vmime::attachment> att = vmime::make_shared <vmime::defaultAttachment>
- (vmime::make_shared <vmime::stringContentHandler>("test"),
- vmime::mediaType("image/jpeg"));
+ vmime::shared_ptr <vmime::attachment> att =
+ vmime::make_shared <vmime::defaultAttachment>(
+ vmime::make_shared <vmime::stringContentHandler>("test"),
+ vmime::mediaType("image/jpeg")
+ );
vmime::attachmentHelper::addAttachment(msg, att);
@@ -96,8 +102,8 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest)
VASSERT_EQ("2", "The text\r\n", extractBodyContents(msg->getBody()->getPartAt(0)));
}
- void testAddAttachment2()
- {
+ void testAddAttachment2() {
+
vmime::string data =
"Content-Type: multipart/mixed; boundary=\"foo\"\r\n"
"\r\n"
@@ -115,9 +121,11 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest)
vmime::shared_ptr <vmime::message> msg = vmime::make_shared <vmime::message>();
msg->parse(data);
- vmime::shared_ptr <vmime::attachment> att = vmime::make_shared <vmime::defaultAttachment>
- (vmime::make_shared <vmime::stringContentHandler>("test"),
- vmime::mediaType("image/jpeg"));
+ vmime::shared_ptr <vmime::attachment> att =
+ vmime::make_shared <vmime::defaultAttachment>(
+ vmime::make_shared <vmime::stringContentHandler>("test"),
+ vmime::mediaType("image/jpeg")
+ );
vmime::attachmentHelper::addAttachment(msg, att);
@@ -128,8 +136,8 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest)
}
// Initial part is encoded
- void testAddAttachment3()
- {
+ void testAddAttachment3() {
+
vmime::string data =
"Content-Type: text/plain\r\n"
"Content-Transfer-Encoding: base64\r\n"
@@ -139,9 +147,11 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest)
vmime::shared_ptr <vmime::message> msg = vmime::make_shared <vmime::message>();
msg->parse(data);
- vmime::shared_ptr <vmime::attachment> att = vmime::make_shared <vmime::defaultAttachment>
- (vmime::make_shared <vmime::stringContentHandler>("test"),
- vmime::mediaType("image/jpeg"));
+ vmime::shared_ptr <vmime::attachment> att =
+ vmime::make_shared <vmime::defaultAttachment>(
+ vmime::make_shared <vmime::stringContentHandler>("test"),
+ vmime::mediaType("image/jpeg")
+ );
vmime::attachmentHelper::addAttachment(msg, att);
@@ -151,8 +161,8 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest)
// Content-Disposition: attachment
// No other field
- void testIsBodyPartAnAttachment1()
- {
+ void testIsBodyPartAnAttachment1() {
+
vmime::string data = "Content-Disposition: attachment\r\n\r\nFoo\r\n";
vmime::shared_ptr <vmime::bodyPart> p = vmime::make_shared <vmime::bodyPart>();
@@ -163,8 +173,8 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest)
// No Content-Disposition field
// Content-Type: multipart/* or text/*
- void testIsBodyPartAnAttachment2()
- {
+ void testIsBodyPartAnAttachment2() {
+
vmime::string data = "Content-Type: multipart/*\r\n\r\nFoo\r\n";
vmime::shared_ptr <vmime::bodyPart> p = vmime::make_shared <vmime::bodyPart>();
@@ -180,8 +190,8 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest)
}
// No Content-Disposition field
- void testIsBodyPartAnAttachment3()
- {
+ void testIsBodyPartAnAttachment3() {
+
vmime::string data = "Content-Type: application/octet-stream\r\n\r\nFoo\r\n";
vmime::shared_ptr <vmime::bodyPart> p = vmime::make_shared <vmime::bodyPart>();
@@ -192,8 +202,8 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest)
// Content-Disposition: attachment
// Content-Id field present
- void testIsBodyPartAnAttachment4()
- {
+ void testIsBodyPartAnAttachment4() {
+
vmime::string data = "Content-Disposition: attachment\r\n"
"Content-Type: application/octet-stream\r\n"
"Content-Id: bar\r\n"
@@ -205,8 +215,8 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest)
VASSERT_EQ("1", false, vmime::attachmentHelper::isBodyPartAnAttachment(p));
}
- void testGetBodyPartAttachment()
- {
+ void testGetBodyPartAttachment() {
+
vmime::string data =
"Content-Type: image/jpeg\r\n"
"Content-Description: foobar\r\n"
@@ -238,8 +248,8 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest)
VASSERT_EQ("7", part->getHeader()->generate(), att->getHeader()->generate());
}
- void testAddAttachmentMessage1()
- {
+ void testAddAttachmentMessage1() {
+
const vmime::string data =
"Subject: Test message\r\n"
"Content-Type: text/plain\r\n"
@@ -282,8 +292,8 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest)
VASSERT_EQ("4", "Attached message body", extractBodyContents(amsgOut));
}
- void testGetBodyPartAttachmentMessage()
- {
+ void testGetBodyPartAttachmentMessage() {
+
const vmime::string data =
"Subject: Test message\r\n"
"Content-Type: multipart/mixed; boundary=\"foo\"\r\n"
@@ -305,8 +315,8 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest)
VASSERT_EQ("0", 2, msg->getBody()->getPartCount());
- vmime::shared_ptr <const vmime::attachment> att = vmime::attachmentHelper::
- getBodyPartAttachment(msg->getBody()->getPartAt(0));
+ vmime::shared_ptr <const vmime::attachment> att =
+ vmime::attachmentHelper::getBodyPartAttachment(msg->getBody()->getPartAt(0));
VASSERT("1", att != NULL);
@@ -323,4 +333,3 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/parser/bodyPartTest.cpp b/tests/parser/bodyPartTest.cpp
index e6ff737a..91742553 100644
--- a/tests/parser/bodyPartTest.cpp
+++ b/tests/parser/bodyPartTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -42,15 +42,21 @@ VMIME_TEST_SUITE_BEGIN(bodyPartTest)
VMIME_TEST_LIST_END
- static const vmime::string extractComponentString
- (const vmime::string& buffer, const vmime::component& c)
- {
- return vmime::string(buffer.begin() + c.getParsedOffset(),
- buffer.begin() + c.getParsedOffset() + c.getParsedLength());
+ static const vmime::string extractComponentString(
+ const vmime::string& buffer,
+ const vmime::component& c
+ ) {
+
+ return vmime::string(
+ buffer.begin() + c.getParsedOffset(),
+ buffer.begin() + c.getParsedOffset() + c.getParsedLength()
+ );
}
- static const vmime::string extractContents(const vmime::shared_ptr <const vmime::contentHandler>& cts)
- {
+ static const vmime::string extractContents(
+ const vmime::shared_ptr <const vmime::contentHandler>& cts
+ ) {
+
std::ostringstream oss;
vmime::utility::outputStreamAdapter os(oss);
@@ -60,8 +66,8 @@ VMIME_TEST_SUITE_BEGIN(bodyPartTest)
}
- void testParse()
- {
+ void testParse() {
+
vmime::string str1 = "HEADER\r\n\r\nBODY";
vmime::bodyPart p1;
p1.parse(str1);
@@ -84,8 +90,8 @@ VMIME_TEST_SUITE_BEGIN(bodyPartTest)
VASSERT_EQ("6", "BODY", extractComponentString(str3, *p3.getBody()));
}
- void testParseMissingLastBoundary()
- {
+ void testParseMissingLastBoundary() {
+
vmime::string str =
"Content-Type: multipart/mixed; boundary=\"MY-BOUNDARY\""
"\r\n\r\n"
@@ -101,8 +107,8 @@ VMIME_TEST_SUITE_BEGIN(bodyPartTest)
VASSERT_EQ("part2-body", "BODY2", extractContents(p.getBody()->getPartAt(1)->getBody()->getContents()));
}
- void testGenerate()
- {
+ void testGenerate() {
+
vmime::bodyPart p1;
p1.getHeader()->getField("Foo")->setValue(vmime::string("bar"));
p1.getBody()->setContents(vmime::make_shared <vmime::stringContentHandler>("Baz"));
@@ -110,8 +116,8 @@ VMIME_TEST_SUITE_BEGIN(bodyPartTest)
VASSERT_EQ("1", "Foo: bar\r\n\r\nBaz", p1.generate());
}
- void testPrologEpilog()
- {
+ void testPrologEpilog() {
+
const char testMail[] =
"From: [email protected]\r\n"
@@ -136,8 +142,8 @@ VMIME_TEST_SUITE_BEGIN(bodyPartTest)
// Test for bug fix: prolog should not be encoded
// http://sourceforge.net/tracker/?func=detail&atid=525568&aid=3174903&group_id=69724
- void testPrologEncoding()
- {
+ void testPrologEncoding() {
+
const char testmail[] =
"From: [email protected]\r\n"
@@ -169,8 +175,8 @@ VMIME_TEST_SUITE_BEGIN(bodyPartTest)
std::string ostr;
vmime::utility::outputStreamStringAdapter out(ostr);
- for (int i = 0 ; i < 10 ; ++i)
- {
+ for (int i = 0 ; i < 10 ; ++i) {
+
ostr.clear();
msg->parse(istr);
@@ -184,8 +190,8 @@ VMIME_TEST_SUITE_BEGIN(bodyPartTest)
VASSERT_EQ("epilog", "Epilog text", msg->getBody()->getEpilogText());
}
- void testSuccessiveBoundaries()
- {
+ void testSuccessiveBoundaries() {
+
vmime::string str =
"Content-Type: multipart/mixed; boundary=\"MY-BOUNDARY\""
"\r\n\r\n"
@@ -202,8 +208,8 @@ VMIME_TEST_SUITE_BEGIN(bodyPartTest)
VASSERT_EQ("part2-body", "", extractContents(p.getBody()->getPartAt(1)->getBody()->getContents()));
}
- void testTransportPaddingInBoundary()
- {
+ void testTransportPaddingInBoundary() {
+
vmime::string str =
"Content-Type: multipart/mixed; boundary=\"MY-BOUNDARY\""
"\r\n\r\n"
@@ -221,8 +227,8 @@ VMIME_TEST_SUITE_BEGIN(bodyPartTest)
}
/** Ensure '7bit' encoding is used when body is 7-bit only. */
- void testGenerate7bit()
- {
+ void testGenerate7bit() {
+
vmime::shared_ptr <vmime::plainTextPart> p1 = vmime::make_shared <vmime::plainTextPart>();
p1->setText(vmime::make_shared <vmime::stringContentHandler>("Part1 is US-ASCII only."));
@@ -233,8 +239,8 @@ VMIME_TEST_SUITE_BEGIN(bodyPartTest)
VASSERT_EQ("1", "7bit", header1->ContentTransferEncoding()->getValue()->generate());
}
- void testTextUsageForQPEncoding()
- {
+ void testTextUsageForQPEncoding() {
+
vmime::shared_ptr <vmime::plainTextPart> part = vmime::make_shared <vmime::plainTextPart>();
part->setText(vmime::make_shared <vmime::stringContentHandler>("Part1-line1\r\nPart1-line2\r\n\x89"));
@@ -255,8 +261,8 @@ VMIME_TEST_SUITE_BEGIN(bodyPartTest)
VASSERT_EQ("2", "Part1-line1\r\nPart1-line2\r\n=89", oss.str());
}
- void testParseGuessBoundary()
- {
+ void testParseGuessBoundary() {
+
// Boundary is not specified in "Content-Type" field
// Parser will try to guess it from message contents.
@@ -276,8 +282,8 @@ VMIME_TEST_SUITE_BEGIN(bodyPartTest)
VASSERT_EQ("part2-body", "BODY2", extractContents(p.getBody()->getPartAt(1)->getBody()->getContents()));
}
- void testParseGuessBoundaryWithTransportPadding()
- {
+ void testParseGuessBoundaryWithTransportPadding() {
+
// Boundary is not specified in "Content-Type" field
// Parser will try to guess it from message contents.
// Transport padding white spaces should be ignored.
@@ -298,8 +304,8 @@ VMIME_TEST_SUITE_BEGIN(bodyPartTest)
VASSERT_EQ("part2-body", "BODY2", extractContents(p.getBody()->getPartAt(1)->getBody()->getContents()));
}
- void testParseVeryBigMessage()
- {
+ void testParseVeryBigMessage() {
+
// When parsing from a seekable input stream, body contents should not
// be kept in memory in a "stringContentHandler" object. Instead, content
// should be accessible via a "streamContentHandler" object.
@@ -323,8 +329,9 @@ VMIME_TEST_SUITE_BEGIN(bodyPartTest)
oss << BODY1_BEGIN;
- for (unsigned int i = 0 ; i < BODY1_REPEAT ; ++i)
+ for (unsigned int i = 0 ; i < BODY1_REPEAT ; ++i) {
oss << BODY1_LINE;
+ }
oss << BODY1_END;
@@ -333,8 +340,9 @@ VMIME_TEST_SUITE_BEGIN(bodyPartTest)
<< "HEADER2\r\n"
<< "\r\n";
- for (unsigned int i = 0 ; i < BODY2_REPEAT ; ++i)
+ for (unsigned int i = 0 ; i < BODY2_REPEAT ; ++i) {
oss << BODY2_LINE;
+ }
oss << "\r\n"
<< "--MY-BOUNDARY--\r\n";
@@ -366,4 +374,3 @@ VMIME_TEST_SUITE_BEGIN(bodyPartTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/parser/bodyTest.cpp b/tests/parser/bodyTest.cpp
index 92a4575e..fa396af5 100644
--- a/tests/parser/bodyTest.cpp
+++ b/tests/parser/bodyTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -32,35 +32,49 @@ VMIME_TEST_SUITE_BEGIN(bodyTest)
VMIME_TEST_LIST_END
- void testGenerate_Text()
- {
+ void testGenerate_Text() {
+
// RFC-2015: [Quoted-Printable encoding] A line break in a text body,
// represented as a CRLF sequence in the text canonical form, must be
// represented by a line break which is also a CRLF sequence, in the
// Quoted-Printable encoding
vmime::bodyPart p;
- p.getBody()->setContents(vmime::make_shared <vmime::stringContentHandler>
- ("Foo éé\r\né bar\r\nbaz"), vmime::mediaType("text", "plain"),
- vmime::charset("utf-8"), vmime::encoding("quoted-printable"));
+ p.getBody()->setContents(
+ vmime::make_shared <vmime::stringContentHandler>(
+ "Foo éé\r\né bar\r\nbaz"
+ ),
+ vmime::mediaType("text", "plain"),
+ vmime::charset("utf-8"),
+ vmime::encoding("quoted-printable")
+ );
- VASSERT_EQ("generate",
+ VASSERT_EQ(
+ "generate",
"Foo =C3=A9=C3=A9\r\n"
"=C3=A9 bar\r\n"
"baz",
- p.getBody()->generate());
+ p.getBody()->generate()
+ );
}
- void testGenerate_NonText()
- {
+ void testGenerate_NonText() {
+
vmime::bodyPart p;
- p.getBody()->setContents(vmime::make_shared <vmime::stringContentHandler>
- ("Binary\xfa\xfb\r\ndata\r\n\r\n\xfc"), vmime::mediaType("application", "octet-stream"),
- vmime::charset("utf-8"), vmime::encoding("quoted-printable"));
+ p.getBody()->setContents(
+ vmime::make_shared <vmime::stringContentHandler>(
+ "Binary\xfa\xfb\r\ndata\r\n\r\n\xfc"
+ ),
+ vmime::mediaType("application", "octet-stream"),
+ vmime::charset("utf-8"),
+ vmime::encoding("quoted-printable")
+ );
- VASSERT_EQ("generate",
+ VASSERT_EQ(
+ "generate",
"Binary=FA=FB=0D=0Adata=0D=0A=0D=0A=FC",
- p.getBody()->generate());
+ p.getBody()->generate()
+ );
}
VMIME_TEST_SUITE_END
diff --git a/tests/parser/charsetFilteredOutputStreamTest.cpp b/tests/parser/charsetFilteredOutputStreamTest.cpp
index 9b8397a8..0ebd83a7 100644
--- a/tests/parser/charsetFilteredOutputStreamTest.cpp
+++ b/tests/parser/charsetFilteredOutputStreamTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -40,8 +40,8 @@ VMIME_TEST_SUITE_BEGIN(charsetFilteredOutputStreamTest)
VMIME_TEST_LIST_END
- void testInputBufferUnderflow()
- {
+ void testInputBufferUnderflow() {
+
vmime::shared_ptr <vmime::charsetConverter> cc =
vmime::charsetConverter::create("utf-8", "iso-8859-1");
@@ -65,8 +65,8 @@ VMIME_TEST_SUITE_BEGIN(charsetFilteredOutputStreamTest)
VASSERT_EQ("chunk 2", toHex("f\xf8o"), toHex(output));
}
- void testInvalidInput1()
- {
+ void testInvalidInput1() {
+
vmime::string in("foo\xab\xcd\xef bar");
vmime::string expectedOut("foo??? bar");
@@ -74,9 +74,7 @@ VMIME_TEST_SUITE_BEGIN(charsetFilteredOutputStreamTest)
vmime::utility::outputStreamStringAdapter osa(actualOut);
vmime::shared_ptr <vmime::charsetConverter> conv =
- vmime::charsetConverter::create
- (vmime::charset("utf-8"),
- vmime::charset("iso-8859-1"));
+ vmime::charsetConverter::create(vmime::charset("utf-8"), vmime::charset("iso-8859-1"));
vmime::shared_ptr <vmime::utility::charsetFilteredOutputStream> os =
conv->getFilteredOutputStream(osa);
@@ -96,10 +94,10 @@ VMIME_TEST_SUITE_BEGIN(charsetFilteredOutputStreamTest)
}
// Using 'bufferedStreamCopy'
- void testStreamCopy()
- {
- for (unsigned int i = 0 ; i < charsetTestSuitesCount ; ++i)
- {
+ void testStreamCopy() {
+
+ for (unsigned int i = 0 ; i < charsetTestSuitesCount ; ++i) {
+
const charsetTestSuiteStruct& entry = charsetTestSuites[i];
std::ostringstream testName;
@@ -133,10 +131,10 @@ VMIME_TEST_SUITE_BEGIN(charsetFilteredOutputStreamTest)
}
// One byte at a time
- void testOneByteAtTime()
- {
- for (unsigned int i = 0 ; i < charsetTestSuitesCount ; ++i)
- {
+ void testOneByteAtTime() {
+
+ for (unsigned int i = 0 ; i < charsetTestSuitesCount ; ++i) {
+
const charsetTestSuiteStruct& entry = charsetTestSuites[i];
std::ostringstream testName;
@@ -173,10 +171,10 @@ VMIME_TEST_SUITE_BEGIN(charsetFilteredOutputStreamTest)
}
// Variable chunks
- void testVariableInputChunk()
- {
- for (unsigned int i = 0 ; i < charsetTestSuitesCount ; ++i)
- {
+ void testVariableInputChunk() {
+
+ for (unsigned int i = 0 ; i < charsetTestSuitesCount ; ++i) {
+
const charsetTestSuiteStruct& entry = charsetTestSuites[i];
std::ostringstream testName;
diff --git a/tests/parser/charsetTest.cpp b/tests/parser/charsetTest.cpp
index e599c5b5..e44bef5b 100644
--- a/tests/parser/charsetTest.cpp
+++ b/tests/parser/charsetTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -52,10 +52,10 @@ VMIME_TEST_SUITE_BEGIN(charsetTest)
VMIME_TEST_LIST_END
- void testConvertStringValid()
- {
- for (unsigned int i = 0 ; i < charsetTestSuitesCount ; ++i)
- {
+ void testConvertStringValid() {
+
+ for (unsigned int i = 0 ; i < charsetTestSuitesCount ; ++i) {
+
const charsetTestSuiteStruct& entry = charsetTestSuites[i];
std::ostringstream testName;
@@ -76,10 +76,10 @@ VMIME_TEST_SUITE_BEGIN(charsetTest)
}
}
- void testConvertStreamValid()
- {
- for (unsigned int i = 0 ; i < charsetTestSuitesCount ; ++i)
- {
+ void testConvertStreamValid() {
+
+ for (unsigned int i = 0 ; i < charsetTestSuitesCount ; ++i) {
+
const charsetTestSuiteStruct& entry = charsetTestSuites[i];
std::ostringstream testName;
@@ -96,8 +96,7 @@ VMIME_TEST_SUITE_BEGIN(charsetTest)
vmime::utility::inputStreamStringAdapter is(in);
- vmime::charset::convert
- (is, os, entry.fromCharset, entry.toCharset);
+ vmime::charset::convert(is, os, entry.fromCharset, entry.toCharset);
os.flush();
@@ -105,8 +104,8 @@ VMIME_TEST_SUITE_BEGIN(charsetTest)
}
}
- void testEncodingHebrew1255()
- {
+ void testEncodingHebrew1255() {
+
// hewbrew string in windows-1255 charset
const char data[] = "\xe9\xf9\xf7\xf8\xe9\xf9\xf8\xf7\xe9\xe9\xf9";
vmime::word w = vmime::word(data, "windows-1255");
@@ -115,11 +114,14 @@ VMIME_TEST_SUITE_BEGIN(charsetTest)
VASSERT_EQ("1", "=?windows-1255?B?6fn3+On5+Pfp6fk=?=", encoded);
}
- static const vmime::string convertHelper
- (const vmime::string& in, const vmime::charset& csrc, const vmime::charset& cdest,
- const vmime::charsetConverterOptions& opts = vmime::charsetConverterOptions(),
- vmime::charsetConverter::status* st = NULL)
- {
+ static const vmime::string convertHelper(
+ const vmime::string& in,
+ const vmime::charset& csrc,
+ const vmime::charset& cdest,
+ const vmime::charsetConverterOptions& opts = vmime::charsetConverterOptions(),
+ vmime::charsetConverter::status* st = NULL
+ ) {
+
vmime::shared_ptr <vmime::charsetConverter> conv =
vmime::charsetConverter::create(csrc, cdest, opts);
@@ -129,8 +131,8 @@ VMIME_TEST_SUITE_BEGIN(charsetTest)
return out;
}
- void testEncodeIDNA()
- {
+ void testEncodeIDNA() {
+
VASSERT_EQ("1", "xn--espaol-zwa", convertHelper("español", "utf-8", "idna"));
// Tests from ICANN
@@ -141,8 +143,8 @@ VMIME_TEST_SUITE_BEGIN(charsetTest)
VASSERT_EQ("3.2", "xn--kgbechtv", convertHelper("إختبار", "utf-8", "idna"));
}
- void testDecodeIDNA()
- {
+ void testDecodeIDNA() {
+
VASSERT_EQ("1", "español", convertHelper("xn--espaol-zwa", "idna", "utf-8"));
// Tests from ICANN
@@ -153,21 +155,23 @@ VMIME_TEST_SUITE_BEGIN(charsetTest)
VASSERT_EQ("3.2", "إختبار", convertHelper("xn--kgbechtv", "idna", "utf-8"));
}
- void testUTF7Support()
- {
+ void testUTF7Support() {
+
// Ensure UTF-7 is supported, because it is used for IMAP
VASSERT_EQ("1", "VMime +- UTF-7 encoding", convertHelper("VMime + UTF-7 encoding", "utf-8", "utf-7"));
VASSERT_EQ("2", "f+APg-o", convertHelper("\x66\xc3\xb8\x6f", "utf-8", "utf-7"));
}
- void testReplaceInvalidSequence()
- {
+ void testReplaceInvalidSequence() {
+
vmime::charsetConverterOptions opts;
opts.silentlyReplaceInvalidSequences = true;
opts.invalidSequence = "?";
- vmime::string res = convertHelper
- ("\x61\xf1\x80\x80\xe1\x80\xc2\x62\x80\x63\x80\xbf\x64", "utf-8", "iso-8859-1", opts);
+ vmime::string res = convertHelper(
+ "\x61\xf1\x80\x80\xe1\x80\xc2\x62\x80\x63\x80\xbf\x64",
+ "utf-8", "iso-8859-1", opts
+ );
// Result should be in the form "a???b?c??d" or "a??????b?c??d"...
// Remove consecutive question marks for easier matching.
@@ -180,8 +184,8 @@ VMIME_TEST_SUITE_BEGIN(charsetTest)
);
}
- void testStopOnInvalidSequence()
- {
+ void testStopOnInvalidSequence() {
+
vmime::charsetConverterOptions opts;
opts.silentlyReplaceInvalidSequences = false;
@@ -192,8 +196,8 @@ VMIME_TEST_SUITE_BEGIN(charsetTest)
);
}
- void testStatus()
- {
+ void testStatus() {
+
vmime::charsetConverterOptions opts;
opts.silentlyReplaceInvalidSequences = false;
@@ -206,23 +210,22 @@ VMIME_TEST_SUITE_BEGIN(charsetTest)
VASSERT_EQ("outputBytesWritten", 7, st.outputBytesWritten);
}
- void testStatusWithInvalidSequence()
- {
+ void testStatusWithInvalidSequence() {
+
vmime::charsetConverterOptions opts;
opts.silentlyReplaceInvalidSequences = false;
vmime::charsetConverter::status st;
- try
- {
+ try {
+
// 01234 5 6789 0 1
convertHelper("Fran\xc3\xa7ois\xf1\x80\x65", "utf-8", "iso-8859-1", opts, &st);
- }
- catch (vmime::exceptions::illegal_byte_sequence_for_charset& e)
- {
- }
- catch (...)
- {
+
+ } catch (vmime::exceptions::illegal_byte_sequence_for_charset& e) {
+
+ } catch (...) {
+
throw;
}
@@ -230,8 +233,8 @@ VMIME_TEST_SUITE_BEGIN(charsetTest)
VASSERT_EQ("outputBytesWritten", 8, st.outputBytesWritten);
}
- void testIsValidText()
- {
+ void testIsValidText() {
+
// Invalid text
const vmime::string invalidText("Fran\xc3\xa7ois\xf1\x80\x65");
vmime::string::size_type firstInvalidByte;
@@ -247,4 +250,3 @@ VMIME_TEST_SUITE_BEGIN(charsetTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/parser/charsetTestSuites.hpp b/tests/parser/charsetTestSuites.hpp
index cb10e29e..9653016b 100644
--- a/tests/parser/charsetTestSuites.hpp
+++ b/tests/parser/charsetTestSuites.hpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -22,8 +22,8 @@
//
-struct charsetTestSuiteStruct
-{
+struct charsetTestSuiteStruct {
+
const char* fromCharset;
const char* toCharset;
const char* fromBytes;
@@ -33,8 +33,8 @@ struct charsetTestSuiteStruct
};
-static const charsetTestSuiteStruct charsetTestSuites[] =
-{
+static const charsetTestSuiteStruct charsetTestSuites[] = {
+
// Test data 1 (excerpt from http://www.gnu.org)
{
"gb2312", "utf-8",
@@ -97,7 +97,6 @@ static const charsetTestSuiteStruct charsetTestSuites[] =
"\xe7\xbb\x9f\x20\xe3\x80\x82\x0a",
0
}
-
};
static const vmime::size_t charsetTestSuitesCount = sizeof(charsetTestSuites) / sizeof(charsetTestSuites[0]);
diff --git a/tests/parser/datetimeTest.cpp b/tests/parser/datetimeTest.cpp
index 90bbebbb..61c85221 100644
--- a/tests/parser/datetimeTest.cpp
+++ b/tests/parser/datetimeTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -33,10 +33,9 @@ VMIME_TEST_SUITE_BEGIN(datetimeTest)
VMIME_TEST_LIST_END
- void testParse()
- {
- struct datetimePair
- {
+ void testParse() {
+
+ struct datetimePair {
vmime::string parseBuffer;
vmime::datetime result;
};
@@ -45,8 +44,8 @@ VMIME_TEST_SUITE_BEGIN(datetimeTest)
// so we test some cases. Don't forget to add a new test case
// each time you encounter a bug in date/time parsing (after
// you have fixed it).
- datetimePair pairs[] =
- {
+ datetimePair pairs[] = {
+
{ /* 1 */ "Mon, 8 Nov 2004 13:42:56 +0000 (GMT)",
vmime::datetime(2004, 11, 8, 13, 42, 56, vmime::datetime::GMT) },
@@ -66,8 +65,8 @@ VMIME_TEST_SUITE_BEGIN(datetimeTest)
vmime::datetime(2004, 11, 18, 21, 44, 54, vmime::datetime::GMT3) }
};
- for (unsigned int i = 0 ; i < sizeof(pairs) / sizeof(pairs[0]) ; ++i)
- {
+ for (unsigned int i = 0 ; i < sizeof(pairs) / sizeof(pairs[0]) ; ++i) {
+
vmime::datetime d;
d.parse(pairs[i].parseBuffer);
@@ -78,15 +77,15 @@ VMIME_TEST_SUITE_BEGIN(datetimeTest)
}
}
- void testGenerate()
- {
+ void testGenerate() {
+
vmime::datetime d1(2005, 7, 8, 4, 5, 6, 1 * 60 + 23);
VASSERT_EQ("1", "Fri, 8 Jul 2005 04:05:06 +0123", d1.generate());
}
- void testCompare()
- {
+ void testCompare() {
+
// Date1 = Date2
vmime::datetime d1(2005, 4, 22, 14, 6, 0, vmime::datetime::GMT2);
vmime::datetime d2(2005, 4, 22, 10, 6, 0, vmime::datetime::GMT_2);
@@ -122,4 +121,3 @@ VMIME_TEST_SUITE_BEGIN(datetimeTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/parser/dispositionTest.cpp b/tests/parser/dispositionTest.cpp
index 7b767caa..f51c51e8 100644
--- a/tests/parser/dispositionTest.cpp
+++ b/tests/parser/dispositionTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -33,8 +33,8 @@ VMIME_TEST_SUITE_BEGIN(dispositionTest)
VMIME_TEST_LIST_END
- void testParse()
- {
+ void testParse() {
+
// disposition-mode ";" disposition-type
// [ "/" disposition-modifier *( "," disposition-modifier ) ]
//
@@ -84,8 +84,8 @@ VMIME_TEST_SUITE_BEGIN(dispositionTest)
VASSERT_EQ("5.6", "modif2", disp5.getModifierList()[1]);
}
- void testGenerate()
- {
+ void testGenerate() {
+
vmime::disposition disp;
VASSERT_EQ("1", "automatic-action/MDN-sent-automatically;displayed", disp.generate());
@@ -112,8 +112,8 @@ VMIME_TEST_SUITE_BEGIN(dispositionTest)
VASSERT_EQ("6", "amode/smode;type/modif1,modif2", disp.generate());
}
- void testModifiers()
- {
+ void testModifiers() {
+
vmime::disposition disp1;
VASSERT_EQ("1", false, disp1.hasModifier("foo"));
@@ -148,4 +148,3 @@ VMIME_TEST_SUITE_BEGIN(dispositionTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/parser/emailAddressTest.cpp b/tests/parser/emailAddressTest.cpp
index 2de401a9..f2a70705 100644
--- a/tests/parser/emailAddressTest.cpp
+++ b/tests/parser/emailAddressTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -45,29 +45,26 @@ VMIME_TEST_SUITE_BEGIN(emailAddressTest)
VMIME_TEST_LIST_END
- void setUp()
- {
+ void setUp() {
+
// Set the global C and C++ locale to the user-configured locale.
// The locale should use UTF-8 encoding for these tests to run successfully.
- try
- {
+ try {
std::locale::global(std::locale(""));
- }
- catch (std::exception &)
- {
+ } catch (std::exception &) {
std::setlocale(LC_ALL, "");
}
}
- void tearDown()
- {
+ void tearDown() {
+
// Restore default locale
std::locale::global(std::locale("C"));
}
- void testParseASCII()
- {
+ void testParseASCII() {
+
vmime::emailAddress eml1("local@domain");
VASSERT_EQ("1/local", "local", eml1.getLocalName());
VASSERT_EQ("1/domain", "domain", eml1.getDomainName());
@@ -78,8 +75,8 @@ VMIME_TEST_SUITE_BEGIN(emailAddressTest)
VASSERT_EQ("2/domain", vmime::platform::getHandler()->getHostName(), eml2.getDomainName());
}
- void testParseEAI()
- {
+ void testParseEAI() {
+
// Examples taken from Wikipedia (http://en.wikipedia.org/wiki/Email_address)
// Latin Alphabet (with diacritics):
@@ -103,8 +100,8 @@ VMIME_TEST_SUITE_BEGIN(emailAddressTest)
VASSERT_EQ("4/domain", "ящик-с-апельсинами.рф", eml4.getDomainName());
}
- void testParseInvalid()
- {
+ void testParseInvalid() {
+
// Only one @ is allowed outside quotation marks
vmime::emailAddress eml1("local@part@domain");
VASSERT_EQ("1/local", "local", eml1.getLocalName());
@@ -132,8 +129,8 @@ VMIME_TEST_SUITE_BEGIN(emailAddressTest)
VASSERT_EQ("5/domain", vmime::platform::getHandler()->getHostName(), eml5.getDomainName());
}
- void testParseSpecialChars()
- {
+ void testParseSpecialChars() {
+
// Examples taken from Wikipedia (http://en.wikipedia.org/wiki/Email_address)
vmime::emailAddress eml1("\" \"@example.org");
@@ -161,8 +158,8 @@ VMIME_TEST_SUITE_BEGIN(emailAddressTest)
VASSERT_EQ("6/domain", "strange.example.com", eml6.getDomainName());
}
- void testParseCommentInLocalPart()
- {
+ void testParseCommentInLocalPart() {
+
vmime::emailAddress eml1("john.smith(comment)@example.com");
VASSERT_EQ("1/local", "john.smith", eml1.getLocalName());
VASSERT_EQ("1/domain", "example.com", eml1.getDomainName());
@@ -180,8 +177,8 @@ VMIME_TEST_SUITE_BEGIN(emailAddressTest)
VASSERT_EQ("4/domain", "example.com", eml4.getDomainName());
}
- void testParseCommentInDomainPart()
- {
+ void testParseCommentInDomainPart() {
+
vmime::emailAddress eml1("john.smith@(comment)example.com");
VASSERT_EQ("1/local", "john.smith", eml1.getLocalName());
VASSERT_EQ("1/domain", "example.com", eml1.getDomainName());
@@ -199,8 +196,8 @@ VMIME_TEST_SUITE_BEGIN(emailAddressTest)
VASSERT_EQ("4/domain", "example.com", eml4.getDomainName());
}
- void testParseRFC2047EncodedLocalPart()
- {
+ void testParseRFC2047EncodedLocalPart() {
+
vmime::emailAddress eml1("[email protected]");
VASSERT_EQ("1/local", "Pelé", eml1.getLocalName());
VASSERT_EQ("1/domain", "example.com", eml1.getDomainName());
@@ -214,47 +211,71 @@ VMIME_TEST_SUITE_BEGIN(emailAddressTest)
VASSERT_EQ("3/domain", "黒川.com", eml3.getDomainName());
}
- void testGenerateASCII()
- {
- VASSERT_EQ("email 1", "local@domain", vmime::emailAddress("local", "domain").generate());
+ void testGenerateASCII() {
- VASSERT_EQ("email 2", "[email protected]",
- vmime::emailAddress("Pelé", "example.com").generate());
- VASSERT_EQ("email 3", "[email protected]",
- vmime::emailAddress("甲斐", "黒川.日本").generate());
- VASSERT_EQ("email 4", "[email protected]",
- vmime::emailAddress("mailtest", "例え.テスト").generate());
- VASSERT_EQ("email 5", "[email protected]",
- vmime::emailAddress("mailtest", "مثال.إختبار").generate());
+ VASSERT_EQ(
+ "email 1", "local@domain",
+ vmime::emailAddress("local", "domain").generate()
+ );
+ VASSERT_EQ(
+ "email 2", "[email protected]",
+ vmime::emailAddress("Pelé", "example.com").generate()
+ );
+ VASSERT_EQ(
+ "email 3", "[email protected]",
+ vmime::emailAddress("甲斐", "黒川.日本").generate()
+ );
+ VASSERT_EQ(
+ "email 4", "[email protected]",
+ vmime::emailAddress("mailtest", "例え.テスト").generate()
+ );
+ VASSERT_EQ(
+ "email 5", "[email protected]",
+ vmime::emailAddress("mailtest", "مثال.إختبار").generate()
+ );
}
- void testGenerateEAI()
- {
+ void testGenerateEAI() {
+
vmime::generationContext ctx(vmime::generationContext::getDefaultContext());
ctx.setInternationalizedEmailSupport(true);
vmime::generationContext::switcher <vmime::generationContext> contextSwitcher(ctx);
- VASSERT_EQ("email 1", "Pelé@example.com",
- vmime::emailAddress("Pelé", "example.com").generate());
- VASSERT_EQ("email 2", "δοκιμή@παράδειγμα.δοκιμή",
- vmime::emailAddress("δοκιμή", "παράδειγμα.δοκιμή").generate());
- VASSERT_EQ("email 3", "甲斐@黒川.日本",
- vmime::emailAddress("甲斐", "黒川.日本").generate());
- VASSERT_EQ("email 4", "чебурашка@ящик-с-апельсинами.рф",
- vmime::emailAddress("чебурашка", "ящик-с-апельсинами.рф").generate());
+ VASSERT_EQ(
+ "email 1", "Pelé@example.com",
+ vmime::emailAddress("Pelé", "example.com").generate()
+ );
+ VASSERT_EQ(
+ "email 2", "δοκιμή@παράδειγμα.δοκιμή",
+ vmime::emailAddress("δοκιμή", "παράδειγμα.δοκιμή").generate()
+ );
+ VASSERT_EQ(
+ "email 3", "甲斐@黒川.日本",
+ vmime::emailAddress("甲斐", "黒川.日本").generate()
+ );
+ VASSERT_EQ(
+ "email 4", "чебурашка@ящик-с-апельсинами.рф",
+ vmime::emailAddress("чебурашка", "ящик-с-апельсинами.рф").generate()
+ );
}
- void testGenerateSpecialChars()
- {
- VASSERT_EQ("email 1", "\"[email protected]\"@example.com",
- vmime::emailAddress("[email protected]", "example.com").generate());
+ void testGenerateSpecialChars() {
+
+ VASSERT_EQ(
+ "email 1", "\"[email protected]\"@example.com",
+ vmime::emailAddress("[email protected]", "example.com").generate()
+ );
- VASSERT_EQ("email 2", "\"very.(),:;<>[]\\\".VERY.\\\"very@\\\\ \\\"very\\\".unusual\"@strange.example.com",
- vmime::emailAddress("very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual", "strange.example.com").generate());
+ VASSERT_EQ(
+ "email 2", "\"very.(),:;<>[]\\\".VERY.\\\"very@\\\\ \\\"very\\\".unusual\"@strange.example.com",
+ vmime::emailAddress("very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual", "strange.example.com").generate()
+ );
- VASSERT_EQ("email 3", "\" \"@example.com",
- vmime::emailAddress(" ", "example.com").generate());
+ VASSERT_EQ(
+ "email 3", "\" \"@example.com",
+ vmime::emailAddress(" ", "example.com").generate()
+ );
}
VMIME_TEST_SUITE_END
diff --git a/tests/parser/emptyContentHandlerTest.cpp b/tests/parser/emptyContentHandlerTest.cpp
index 81e2ed6b..43cd8c2b 100644
--- a/tests/parser/emptyContentHandlerTest.cpp
+++ b/tests/parser/emptyContentHandlerTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -38,30 +38,30 @@ VMIME_TEST_SUITE_BEGIN(emptyContentHandlerTest)
VMIME_TEST_LIST_END
- void testIsEmpty()
- {
+ void testIsEmpty() {
+
vmime::emptyContentHandler cth;
VASSERT_TRUE("empty", cth.isEmpty());
}
- void testGetLength()
- {
+ void testGetLength() {
+
vmime::emptyContentHandler cth;
VASSERT_EQ("length", 0, cth.getLength());
}
- void testIsEncoded()
- {
+ void testIsEncoded() {
+
vmime::emptyContentHandler cth;
VASSERT_FALSE("encoded", cth.isEncoded());
VASSERT_EQ("encoding", vmime::contentHandler::NO_ENCODING, cth.getEncoding());
}
- void testExtract()
- {
+ void testExtract() {
+
vmime::emptyContentHandler cth;
std::ostringstream oss;
@@ -72,8 +72,8 @@ VMIME_TEST_SUITE_BEGIN(emptyContentHandlerTest)
VASSERT_EQ("extract", "", oss.str());
}
- void testExtractRaw()
- {
+ void testExtractRaw() {
+
vmime::emptyContentHandler cth;
std::ostringstream oss;
@@ -84,8 +84,8 @@ VMIME_TEST_SUITE_BEGIN(emptyContentHandlerTest)
VASSERT_EQ("extractRaw", "", oss.str());
}
- void testGenerate()
- {
+ void testGenerate() {
+
vmime::emptyContentHandler cth;
std::ostringstream oss;
diff --git a/tests/parser/fileContentHandlerTest.cpp b/tests/parser/fileContentHandlerTest.cpp
index 9d1459db..e979b52f 100644
--- a/tests/parser/fileContentHandlerTest.cpp
+++ b/tests/parser/fileContentHandlerTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -42,8 +42,8 @@ VMIME_TEST_SUITE_BEGIN(fileContentHandlerTest)
vmime::string testDataEncoded, testDataDecoded;
- void setUp()
- {
+ void setUp() {
+
testDataDecoded = "ABCDEFGHIJKLMNOPQRSTUVWXYZ \x12\x34\x56\x78\x90 abcdefghijklmnopqrstuvwxyz0123456789";
testDataEncoded = "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVogEjRWeJAgYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXowMTIzNDU2Nzg5";
@@ -58,38 +58,38 @@ VMIME_TEST_SUITE_BEGIN(fileContentHandlerTest)
testFile->getFileWriter()->getOutputStream()->write(testDataEncoded.data(), testDataEncoded.length());
}
- void tearDown()
- {
+ void tearDown() {
+
testFile->remove();
testFile = vmime::null;
}
- void testIsEmpty()
- {
+ void testIsEmpty() {
+
vmime::fileContentHandler cth;
VASSERT_TRUE("empty", cth.isEmpty());
}
- void testGetLength()
- {
+ void testGetLength() {
+
vmime::fileContentHandler cth(testFile);
VASSERT_FALSE("empty", cth.isEmpty());
VASSERT_EQ("length", testDataEncoded.length(), cth.getLength());
}
- void testIsEncoded()
- {
+ void testIsEncoded() {
+
vmime::fileContentHandler cth(testFile, vmime::encoding("base64"));
VASSERT_TRUE("encoded", cth.isEncoded());
VASSERT_EQ("encoding", "base64", cth.getEncoding().generate());
}
- void testExtract()
- {
+ void testExtract() {
+
vmime::fileContentHandler cth(testFile, vmime::encoding("base64"));
std::ostringstream oss;
@@ -101,8 +101,8 @@ VMIME_TEST_SUITE_BEGIN(fileContentHandlerTest)
VASSERT_EQ("extract", testDataDecoded, oss.str());
}
- void testExtractRaw()
- {
+ void testExtractRaw() {
+
vmime::fileContentHandler cth(testFile, vmime::encoding("base64"));
std::ostringstream oss;
@@ -114,8 +114,8 @@ VMIME_TEST_SUITE_BEGIN(fileContentHandlerTest)
VASSERT_EQ("extractRaw", testDataEncoded, oss.str());
}
- void testGenerate()
- {
+ void testGenerate() {
+
vmime::fileContentHandler cth(testFile, vmime::encoding("base64"));
std::ostringstream oss;
@@ -124,8 +124,11 @@ VMIME_TEST_SUITE_BEGIN(fileContentHandlerTest)
cth.generate(osa, vmime::encoding("quoted-printable"));
// Data should be reencoded from B64 to QP
- VASSERT_EQ("generate",
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ =124Vx=90 abcdefghijklmnopqrstuvwxyz0123456789", oss.str());
+ VASSERT_EQ(
+ "generate",
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ =124Vx=90 abcdefghijklmnopqrstuvwxyz0123456789",
+ oss.str()
+ );
}
VMIME_TEST_SUITE_END
diff --git a/tests/parser/headerFieldTest.cpp b/tests/parser/headerFieldTest.cpp
index 0642dae7..78d04800 100644
--- a/tests/parser/headerFieldTest.cpp
+++ b/tests/parser/headerFieldTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -34,27 +34,35 @@ VMIME_TEST_SUITE_BEGIN(headerFieldTest)
VMIME_TEST_LIST_END
- void testBadValueType()
- {
+ void testBadValueType() {
+
vmime::shared_ptr <vmime::headerFieldFactory> hfactory =
vmime::headerFieldFactory::getInstance();
// "To" header field accepts values of type "addressList"
vmime::shared_ptr <vmime::headerField> to = hfactory->create(vmime::fields::TO);
- VASSERT_THROW("to",
+
+ VASSERT_THROW(
+ "to",
to->setValue(vmime::mailbox("[email protected]")),
- vmime::exceptions::bad_field_value_type);
+ vmime::exceptions::bad_field_value_type
+ );
// Unregistered header field accepts any value type
vmime::shared_ptr <vmime::headerField> custom = hfactory->create("X-MyCustomHeader");
- VASSERT_NO_THROW("custom/1",
- custom->setValue(vmime::mailbox("[email protected]")));
- VASSERT_NO_THROW("custom/2",
- custom->setValue(vmime::text("field value text")));
+
+ VASSERT_NO_THROW(
+ "custom/1",
+ custom->setValue(vmime::mailbox("[email protected]"))
+ );
+ VASSERT_NO_THROW(
+ "custom/2",
+ custom->setValue(vmime::text("field value text"))
+ );
}
- void testValueOnNextLine()
- {
+ void testValueOnNextLine() {
+
vmime::parsingContext ctx;
const vmime::string buffer = "Field: \r\n\tfield data";
@@ -69,8 +77,8 @@ VMIME_TEST_SUITE_BEGIN(headerFieldTest)
VASSERT_EQ("Field value", "field data", hvalue->getWholeBuffer());
}
- void testStripSpacesAtEnd()
- {
+ void testStripSpacesAtEnd() {
+
vmime::parsingContext ctx;
const vmime::string buffer = "Field: \r\n\tfield data ";
@@ -85,8 +93,8 @@ VMIME_TEST_SUITE_BEGIN(headerFieldTest)
VASSERT_EQ("Field value", toHex("field data"), toHex(hvalue->getWholeBuffer()));
}
- void testValueWithEmptyLine()
- {
+ void testValueWithEmptyLine() {
+
vmime::parsingContext ctx;
const vmime::string buffer = "Field: \r\n\tdata1\r\n\tdata2\r\n\t\r\n\tdata3";
diff --git a/tests/parser/headerTest.cpp b/tests/parser/headerTest.cpp
index 959fc631..839acee5 100644
--- a/tests/parser/headerTest.cpp
+++ b/tests/parser/headerTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -64,18 +64,18 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
VMIME_TEST_LIST_END
- static const std::string getFieldValue(const vmime::headerField& field)
- {
+ static const std::string getFieldValue(const vmime::headerField& field) {
+
std::ostringstream oss;
vmime::utility::outputStreamAdapter voss(oss);
field.generate(voss);
- return (oss.str());
+ return oss.str();
}
// has function tests
- void testHas1()
- {
+ void testHas1() {
+
vmime::header hdr;
hdr.parse("From: x\r\nTo: y\r\nTo: z\r\n");
@@ -84,8 +84,8 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
VASSERT_EQ("Value", false, res);
}
- void testHas2()
- {
+ void testHas2() {
+
vmime::header hdr;
hdr.parse("X: x\r\nTo: y\r\nTo: z\r\n");
@@ -95,8 +95,8 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
}
// appendField function tests
- void testAppend1()
- {
+ void testAppend1() {
+
vmime::header hdr;
hdr.parse("");
@@ -109,8 +109,8 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res[0]));
}
- void testAppend2()
- {
+ void testAppend2() {
+
vmime::header hdr;
hdr.parse("A: a\r\n");
@@ -125,8 +125,8 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
}
// insertFieldBefore
- void testInsertFieldBefore1()
- {
+ void testInsertFieldBefore1() {
+
vmime::header hdr;
hdr.parse("A: a\r\nC: c\r\n");
@@ -141,8 +141,8 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
VASSERT_EQ("Third value", "C: c", headerTest::getFieldValue(*res[2]));
}
- void testInsertFieldBefore2()
- {
+ void testInsertFieldBefore2() {
+
vmime::header hdr;
hdr.parse("A: a\r\nC: c\r\n");
@@ -158,8 +158,8 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
}
// insertFieldAfter
- void testInsertFieldAfter1()
- {
+ void testInsertFieldAfter1() {
+
vmime::header hdr;
hdr.parse("A: a\r\nC: c\r\n");
@@ -174,8 +174,8 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
VASSERT_EQ("Third value", "C: c", headerTest::getFieldValue(*res[2]));
}
- void testInsertFieldAfter2()
- {
+ void testInsertFieldAfter2() {
+
vmime::header hdr;
hdr.parse("A: a\r\nC: c\r\n");
@@ -191,8 +191,8 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
}
// replaceField
- void testReplaceField()
- {
+ void testReplaceField() {
+
vmime::header hdr;
hdr.parse("A: a\r\nB: b\r\nC: c\r\n");
@@ -208,8 +208,8 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
}
// removeField
- void testRemoveField1()
- {
+ void testRemoveField1() {
+
vmime::header hdr1, hdr2;
hdr1.parse("A: a\r\nB: b\r\nC: c\r\n");
hdr2.parse("A: a\r\nB: b\r\nC: c\r\n");
@@ -230,8 +230,8 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
VASSERT_EQ("Second value", "C: c", headerTest::getFieldValue(*res2[1]));
}
- void testRemoveField2()
- {
+ void testRemoveField2() {
+
vmime::header hdr1, hdr2;
hdr1.parse("A: a\r\n");
hdr2.parse("A: a\r\n");
@@ -247,8 +247,8 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
}
// removeAllFields
- void testRemoveAllFields()
- {
+ void testRemoveAllFields() {
+
vmime::header hdr1, hdr2;
hdr1.parse("A: a\r\n");
hdr2.parse("A: a\r\nB: b\r\n");
@@ -264,8 +264,8 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
}
// getFieldCount
- void testgetFieldCount()
- {
+ void testgetFieldCount() {
+
vmime::header hdr;
hdr.parse("A: a\r\nB: b\r\nC: c\r\nD: d\r\n");
@@ -273,16 +273,16 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
}
// isEmpty
- void testIsEmpty1()
- {
+ void testIsEmpty1() {
+
vmime::header hdr;
hdr.parse("A: a\r\nB: b\r\nC: c\r\n");
VASSERT_EQ("Value", false, hdr.isEmpty());
}
- void testIsEmpty2()
- {
+ void testIsEmpty2() {
+
vmime::header hdr;
hdr.parse("\r\n");
@@ -290,8 +290,8 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
}
// getFieldAt
- void testGetFieldAt()
- {
+ void testGetFieldAt() {
+
vmime::header hdr;
hdr.parse("B: b\r\nA: a\r\nC: c\r\n");
@@ -301,8 +301,8 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
}
// getFieldList
- void testGetFieldList1()
- {
+ void testGetFieldList1() {
+
vmime::header hdr;
hdr.parse("A: a\r\nB: b1\r\nC: c\r\nB: b2\r\n");
@@ -315,8 +315,8 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
VASSERT_EQ("Thourth value", "B: b2", headerTest::getFieldValue(*res[3]));
}
- void testGetFieldList2()
- {
+ void testGetFieldList2() {
+
vmime::header hdr;
hdr.parse("\r\n");
@@ -326,8 +326,8 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
}
// find function tests
- void testFind1()
- {
+ void testFind1() {
+
vmime::header hdr;
hdr.parse("A: a\r\nB: b\r\nC: c\r\nB: d\r\n");
@@ -337,8 +337,8 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
}
// getAllByName function tests
- void testFindAllFields1()
- {
+ void testFindAllFields1() {
+
vmime::header hdr;
hdr.parse("A: a1\nC: c1\n");
@@ -347,8 +347,8 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
VASSERT_EQ("Count", static_cast <unsigned int>(0), res.size());
}
- void testFindAllFields2()
- {
+ void testFindAllFields2() {
+
vmime::header hdr;
hdr.parse("A: a1\nB: b1\nB: b2\nC: c1\n");
@@ -359,8 +359,8 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
VASSERT_EQ("Second value", "B: b2", headerTest::getFieldValue(*res[1]));
}
- void testFindAllFields3()
- {
+ void testFindAllFields3() {
+
vmime::header hdr;
hdr.parse("A: a1\nB: b1\nB: b2\nC: c1\nC: c3\nC: c2\n");
@@ -373,4 +373,3 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/parser/htmlTextPartTest.cpp b/tests/parser/htmlTextPartTest.cpp
index 9eef5e84..6dfaaa0b 100644
--- a/tests/parser/htmlTextPartTest.cpp
+++ b/tests/parser/htmlTextPartTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -34,9 +34,10 @@ VMIME_TEST_SUITE_BEGIN(htmlTextPartTest)
VMIME_TEST_LIST_END
- static const vmime::string extractContent
- (const vmime::shared_ptr <const vmime::contentHandler>& cth)
- {
+ static const vmime::string extractContent(
+ const vmime::shared_ptr <const vmime::contentHandler>& cth
+ ) {
+
std::ostringstream oss;
vmime::utility::outputStreamAdapter osa(oss);
@@ -46,8 +47,8 @@ VMIME_TEST_SUITE_BEGIN(htmlTextPartTest)
}
- void testParseText()
- {
+ void testParseText() {
+
const vmime::string msgString = ""
"MIME-Version: 1.0\r\n"
"Content-Type: multipart/alternative; boundary=\"LEVEL1\"\r\n"
@@ -94,8 +95,8 @@ VMIME_TEST_SUITE_BEGIN(htmlTextPartTest)
/** Test parsing of embedded objects by CID (Content-Id).
*/
- void testParseEmbeddedObjectsCID()
- {
+ void testParseEmbeddedObjectsCID() {
+
const vmime::string msgString = ""
"MIME-Version: 1.0\r\n"
"Content-Type: multipart/alternative; boundary=\"LEVEL1\"\r\n"
@@ -137,8 +138,10 @@ VMIME_TEST_SUITE_BEGIN(htmlTextPartTest)
VASSERT_EQ("part-count2", 3, msg->getBody()->getPartAt(1)->getBody()->getPartCount());
vmime::htmlTextPart htmlPart;
- htmlPart.parse(msg, msg->getBody()->getPartAt(1),
- msg->getBody()->getPartAt(1)->getBody()->getPartAt(1));
+ htmlPart.parse(
+ msg, msg->getBody()->getPartAt(1),
+ msg->getBody()->getPartAt(1)->getBody()->getPartAt(1)
+ );
// Two embedded objects should be found.
// BUGFIX: "CID:" prefix is not case-sensitive.
@@ -172,8 +175,8 @@ VMIME_TEST_SUITE_BEGIN(htmlTextPartTest)
/** Test parsing of embedded objects by location.
*/
- void testParseEmbeddedObjectsLocation()
- {
+ void testParseEmbeddedObjectsLocation() {
+
const vmime::string msgString = ""
"MIME-Version: 1.0\r\n"
"Content-Type: multipart/alternative; boundary=\"LEVEL1\"\r\n"
@@ -209,8 +212,10 @@ VMIME_TEST_SUITE_BEGIN(htmlTextPartTest)
VASSERT_EQ("part-count2", 2, msg->getBody()->getPartAt(1)->getBody()->getPartCount());
vmime::htmlTextPart htmlPart;
- htmlPart.parse(msg, msg->getBody()->getPartAt(1),
- msg->getBody()->getPartAt(1)->getBody()->getPartAt(1));
+ htmlPart.parse(
+ msg, msg->getBody()->getPartAt(1),
+ msg->getBody()->getPartAt(1)->getBody()->getPartAt(1)
+ );
// Only one embedded object
VASSERT_EQ("count", 1, htmlPart.getObjectCount());
@@ -234,4 +239,3 @@ VMIME_TEST_SUITE_BEGIN(htmlTextPartTest)
// TODO: test generation of text parts
VMIME_TEST_SUITE_END
-
diff --git a/tests/parser/mailboxGroupTest.cpp b/tests/parser/mailboxGroupTest.cpp
index 6c1319da..11a7f08f 100644
--- a/tests/parser/mailboxGroupTest.cpp
+++ b/tests/parser/mailboxGroupTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -34,8 +34,8 @@ VMIME_TEST_SUITE_BEGIN(mailboxGroupTest)
VMIME_TEST_LIST_END
- void testParseExtraWhitespaces()
- {
+ void testParseExtraWhitespaces() {
+
vmime::mailboxGroup mgrp;
mgrp.parse(" \t group : aaa <[email protected]>, bbb <[email protected]>");
@@ -49,8 +49,8 @@ VMIME_TEST_SUITE_BEGIN(mailboxGroupTest)
VASSERT_EQ("mbox2.name", "bbb", mgrp.getMailboxAt(1)->getName());
}
- void testParseNoEndDelimiter()
- {
+ void testParseNoEndDelimiter() {
+
vmime::addressList addrs;
addrs.parse("group: aaa <[email protected]>, bbb <[email protected]>");
@@ -70,8 +70,8 @@ VMIME_TEST_SUITE_BEGIN(mailboxGroupTest)
VASSERT_EQ("mbox2.name", "bbb", mgrp->getMailboxAt(1)->getName());
}
- void testParseExtraChars()
- {
+ void testParseExtraChars() {
+
vmime::mailboxGroup mgrp;
mgrp.parse("group: aaa <[email protected]>, bbb <[email protected]>; extra chars here...");
@@ -85,8 +85,8 @@ VMIME_TEST_SUITE_BEGIN(mailboxGroupTest)
VASSERT_EQ("mbox2.name", "bbb", mgrp.getMailboxAt(1)->getName());
}
- void testEmptyGroup()
- {
+ void testEmptyGroup() {
+
vmime::mailboxGroup mgrp;
mgrp.parse("Undisclosed recipients:;");
diff --git a/tests/parser/mailboxListTest.cpp b/tests/parser/mailboxListTest.cpp
index c921069e..7505acd9 100644
--- a/tests/parser/mailboxListTest.cpp
+++ b/tests/parser/mailboxListTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -32,8 +32,8 @@ VMIME_TEST_SUITE_BEGIN(mailboxListTest)
// Disposition-Notification-To:: <[email protected]>
- void testParseGroup()
- {
+ void testParseGroup() {
+
// Groups should be extracted to multiple mailboxes in mailbox lists
vmime::mailboxList mboxList;
@@ -45,4 +45,3 @@ VMIME_TEST_SUITE_BEGIN(mailboxListTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/parser/mailboxTest.cpp b/tests/parser/mailboxTest.cpp
index 92fcd98f..127bb422 100644
--- a/tests/parser/mailboxTest.cpp
+++ b/tests/parser/mailboxTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -34,10 +34,10 @@ VMIME_TEST_SUITE_BEGIN(mailboxTest)
VMIME_TEST_LIST_END
- void testParse()
- {
- static const vmime::string testSuitesParse[] =
- {
+ void testParse() {
+
+ static const vmime::string testSuitesParse[] = {
+
// Test 1
"My (this is a comment)name <me(another \\)comment) @ somewhere(else).com>",
@@ -94,8 +94,8 @@ VMIME_TEST_SUITE_BEGIN(mailboxTest)
"[address-list: [[mailbox: name=[text: [[word: charset=us-ascii, buffer=John]]], [email protected]]]]"
};
- for (unsigned int i = 0 ; i < sizeof(testSuitesParse) / sizeof(testSuitesParse[0]) / 2 ; ++i)
- {
+ for (unsigned int i = 0 ; i < sizeof(testSuitesParse) / sizeof(testSuitesParse[0]) / 2 ; ++i) {
+
vmime::string in = testSuitesParse[i * 2];
vmime::string out = testSuitesParse[i * 2 + 1];
@@ -112,8 +112,8 @@ VMIME_TEST_SUITE_BEGIN(mailboxTest)
}
}
- void testEmptyEmailAddress()
- {
+ void testEmptyEmailAddress() {
+
vmime::addressList addrList;
addrList.parse("\"Full Name\" <>");
@@ -127,8 +127,8 @@ VMIME_TEST_SUITE_BEGIN(mailboxTest)
VASSERT_EQ("email", "", mbox->getEmail());
}
- void testSeparatorInComment()
- {
+ void testSeparatorInComment() {
+
vmime::addressList addrList;
addrList.parse("aaa(comment,comment)@vmime.org, [email protected]");
@@ -146,8 +146,8 @@ VMIME_TEST_SUITE_BEGIN(mailboxTest)
VASSERT_EQ("email2", "[email protected]", mbox2->getEmail());
}
- void testAddressInName()
- {
+ void testAddressInName() {
+
vmime::mailbox mbox;
@@ -156,4 +156,3 @@ VMIME_TEST_SUITE_BEGIN(mailboxTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/parser/mediaTypeTest.cpp b/tests/parser/mediaTypeTest.cpp
index 4002b714..e98cfcda 100644
--- a/tests/parser/mediaTypeTest.cpp
+++ b/tests/parser/mediaTypeTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -35,8 +35,8 @@ VMIME_TEST_SUITE_BEGIN(mediaTypeTest)
VMIME_TEST_LIST_END
- void testConstructors()
- {
+ void testConstructors() {
+
vmime::mediaType t1;
VASSERT_EQ("1.1", vmime::mediaTypes::APPLICATION, t1.getType());
@@ -53,8 +53,8 @@ VMIME_TEST_SUITE_BEGIN(mediaTypeTest)
VASSERT_EQ("3.2", "sub", t3.getSubType());
}
- void testCopy()
- {
+ void testCopy() {
+
vmime::mediaType t1("type/sub");
VASSERT_EQ("eq1", "type", t1.getType());
@@ -72,8 +72,8 @@ VMIME_TEST_SUITE_BEGIN(mediaTypeTest)
VASSERT("copyFrom", t1 == t2);
}
- void testSetFromString()
- {
+ void testSetFromString() {
+
vmime::mediaType t1;
t1.setFromString("type/sub");
@@ -81,8 +81,8 @@ VMIME_TEST_SUITE_BEGIN(mediaTypeTest)
VASSERT_EQ("1.2", "sub", t1.getSubType());
}
- void testParse()
- {
+ void testParse() {
+
vmime::mediaType t1;
t1.parse("type/sub");
@@ -90,12 +90,11 @@ VMIME_TEST_SUITE_BEGIN(mediaTypeTest)
VASSERT_EQ("1.2", "sub", t1.getSubType());
}
- void testGenerate()
- {
+ void testGenerate() {
+
vmime::mediaType t1("type", "sub");
VASSERT_EQ("1", "type/sub", t1.generate());
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/parser/messageIdSequenceTest.cpp b/tests/parser/messageIdSequenceTest.cpp
index bc5c7617..0237108d 100644
--- a/tests/parser/messageIdSequenceTest.cpp
+++ b/tests/parser/messageIdSequenceTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -32,8 +32,8 @@ VMIME_TEST_SUITE_BEGIN(messageIdSequenceTest)
VMIME_TEST_LIST_END
- void testParse()
- {
+ void testParse() {
+
vmime::messageIdSequence s1;
s1.parse("");
@@ -61,8 +61,8 @@ VMIME_TEST_SUITE_BEGIN(messageIdSequenceTest)
VASSERT_EQ("4.5", "d", s4.getMessageIdAt(1)->getRight());
}
- void testGenerate()
- {
+ void testGenerate() {
+
vmime::messageIdSequence s1;
s1.appendMessageId(vmime::make_shared <vmime::messageId>("a", "b"));
@@ -76,4 +76,3 @@ VMIME_TEST_SUITE_BEGIN(messageIdSequenceTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/parser/messageIdTest.cpp b/tests/parser/messageIdTest.cpp
index 9863ae51..84330939 100644
--- a/tests/parser/messageIdTest.cpp
+++ b/tests/parser/messageIdTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -33,8 +33,8 @@ VMIME_TEST_SUITE_BEGIN(messageIdTest)
VMIME_TEST_LIST_END
- void testParse()
- {
+ void testParse() {
+
vmime::messageId m1;
m1.parse("<a@b>");
@@ -42,8 +42,8 @@ VMIME_TEST_SUITE_BEGIN(messageIdTest)
VASSERT_EQ("1.2", "b", m1.getRight());
}
- void testParseInvalid()
- {
+ void testParseInvalid() {
+
vmime::messageId m1;
m1.parse("foo@bar");
@@ -51,8 +51,8 @@ VMIME_TEST_SUITE_BEGIN(messageIdTest)
VASSERT_EQ("1.2", "bar", m1.getRight());
}
- void testGenerate()
- {
+ void testGenerate() {
+
vmime::messageId m1;
VASSERT_EQ("1", "<>", m1.generate());
@@ -75,4 +75,3 @@ VMIME_TEST_SUITE_BEGIN(messageIdTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/parser/messageTest.cpp b/tests/parser/messageTest.cpp
index 3891b47e..b89d63e5 100644
--- a/tests/parser/messageTest.cpp
+++ b/tests/parser/messageTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -31,16 +31,24 @@ VMIME_TEST_SUITE_BEGIN(messageTest)
VMIME_TEST_LIST_END
- void testGetGeneratedSize()
- {
+ void testGetGeneratedSize() {
+
vmime::generationContext ctx;
vmime::shared_ptr <vmime::message> msg = vmime::make_shared <vmime::message>();
msg->getHeader()->getField("Foo")->setValue(vmime::string("bar"));
vmime::htmlTextPart textPart;
- textPart.setPlainText(vmime::make_shared <vmime::stringContentHandler>("Foo bar bazé foo foo foo"));
- textPart.setText(vmime::make_shared <vmime::stringContentHandler>("Foo bar <strong>bazé</strong> foo foo foo"));
+ textPart.setPlainText(
+ vmime::make_shared <vmime::stringContentHandler>(
+ "Foo bar bazé foo foo foo"
+ )
+ );
+ textPart.setText(
+ vmime::make_shared <vmime::stringContentHandler>(
+ "Foo bar <strong>bazé</strong> foo foo foo"
+ )
+ );
textPart.generateIn(msg, msg);
// Estimated/computed generated size must be greater than the actual generated size
@@ -54,4 +62,3 @@ VMIME_TEST_SUITE_BEGIN(messageTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/parser/parameterTest.cpp b/tests/parser/parameterTest.cpp
index 0cf2099f..464c3059 100644
--- a/tests/parser/parameterTest.cpp
+++ b/tests/parser/parameterTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -45,12 +45,12 @@ VMIME_TEST_SUITE_BEGIN(parameterTest)
// HACK: parameterizedHeaderField constructor is private
- class parameterizedHeaderField : public vmime::parameterizedHeaderField
- {
+ class parameterizedHeaderField : public vmime::parameterizedHeaderField {
+
public:
- parameterizedHeaderField()
- {
+ parameterizedHeaderField() {
+
setName("F");
setValue(vmime::headerFieldFactory::getInstance()->createValue(getName()));
setValue(vmime::word("X"));
@@ -58,15 +58,17 @@ VMIME_TEST_SUITE_BEGIN(parameterTest)
using vmime::parameterizedHeaderField::generate;
- const vmime::string generate
- (const vmime::generationContext::EncodedParameterValueModes genMode,
- const vmime::size_t maxLineLength = 0) const
- {
+ const vmime::string generate(
+ const vmime::generationContext::EncodedParameterValueModes genMode,
+ const vmime::size_t maxLineLength = 0
+ ) const {
+
vmime::generationContext ctx(vmime::generationContext::getDefaultContext());
ctx.setEncodedParameterValueMode(genMode);
- if (maxLineLength != 0)
+ if (maxLineLength != 0) {
ctx.setMaxLineLength(maxLineLength);
+ }
std::ostringstream oss;
vmime::utility::outputStreamAdapter adapter(oss);
@@ -78,15 +80,17 @@ VMIME_TEST_SUITE_BEGIN(parameterTest)
};
- const vmime::string generateParameter
- (const vmime::parameter& param,
- const vmime::generationContext& ctx,
- const vmime::size_t maxLineLength = 0) const
- {
+ const vmime::string generateParameter(
+ const vmime::parameter& param,
+ const vmime::generationContext& ctx,
+ const vmime::size_t maxLineLength = 0
+ ) const {
+
vmime::generationContext ctx2(ctx);
- if (maxLineLength != 0)
+ if (maxLineLength != 0) {
ctx2.setMaxLineLength(maxLineLength);
+ }
std::ostringstream oss;
vmime::utility::outputStreamAdapter adapter(oss);
@@ -108,29 +112,26 @@ VMIME_TEST_SUITE_BEGIN(parameterTest)
(p.getParameterAt(n)->getValue().getBuffer())
- void setUp()
- {
+ void setUp() {
+
// Set the global C and C++ locale to the user-configured locale.
// The locale should use UTF-8 encoding for these tests to run successfully.
- try
- {
+ try {
std::locale::global(std::locale(""));
- }
- catch (std::exception &)
- {
+ } catch (std::exception &) {
std::setlocale(LC_ALL, "");
}
}
- void tearDown()
- {
+ void tearDown() {
+
// Restore default locale
std::locale::global(std::locale("C"));
}
- void testParse()
- {
+ void testParse() {
+
// Simple parameter
parameterizedHeaderField p1;
p1.parse("X; param1=value1;\r\n");
@@ -141,9 +142,11 @@ VMIME_TEST_SUITE_BEGIN(parameterTest)
// Multi-section parameters (1/2)
parameterizedHeaderField p2a;
- p2a.parse("X; param1=value1;\r\n"
- " param2*0=\"val\";\r\n"
- " param2*1=\"ue2\";");
+ p2a.parse(
+ "X; param1=value1;\r\n"
+ " param2*0=\"val\";\r\n"
+ " param2*1=\"ue2\";"
+ );
VASSERT_EQ("2a.1", 2, p2a.getParameterCount());
VASSERT_EQ("2a.2", "param1", PARAM_NAME(p2a, 0));
@@ -153,10 +156,12 @@ VMIME_TEST_SUITE_BEGIN(parameterTest)
// Multi-section parameters (2/2)
parameterizedHeaderField p2b;
- p2b.parse("X; param1=value1;\r\n"
- " param2=\"should be ignored\";\r\n"
- " param2*0=\"val\";\r\n"
- " param2*1=\"ue2\";");
+ p2b.parse(
+ "X; param1=value1;\r\n"
+ " param2=\"should be ignored\";\r\n"
+ " param2*0=\"val\";\r\n"
+ " param2*1=\"ue2\";"
+ );
VASSERT_EQ("2b.1", 2, p2b.getParameterCount());
VASSERT_EQ("2b.2", "param1", PARAM_NAME(p2b, 0));
@@ -206,13 +211,15 @@ VMIME_TEST_SUITE_BEGIN(parameterTest)
VASSERT_EQ("7.3", "this is a slash: \"\\\"", PARAM_VALUE(p7, 0));
}
- void testParseRFC2231()
- {
+ void testParseRFC2231() {
+
// Extended parameter with charset specified in more than one
// section (this is forbidden by RFC, but is should not fail)
parameterizedHeaderField p1;
- p1.parse("X; param1*0*=charset1'language1'value1;\r\n"
- " param1*1*=charset2'language2'value2;");
+ p1.parse(
+ "X; param1*0*=charset1'language1'value1;\r\n"
+ " param1*1*=charset2'language2'value2;"
+ );
VASSERT_EQ("1.1", 1, p1.getParameterCount());
VASSERT_EQ("1.2", "param1", PARAM_NAME(p1, 0));
@@ -222,8 +229,10 @@ VMIME_TEST_SUITE_BEGIN(parameterTest)
// Charset not specified in the first section (that is not encoded),
// but specified in the second one (legal)
parameterizedHeaderField p2;
- p2.parse("X; param1*0=value1;\r\n"
- " param1*1*=charset'language'value2;");
+ p2.parse(
+ "X; param1*0=value1;\r\n"
+ " param1*1*=charset'language'value2;"
+ );
VASSERT_EQ("2.1", 1, p2.getParameterCount());
VASSERT_EQ("2.2", "param1", PARAM_NAME(p2, 0));
@@ -241,9 +250,11 @@ VMIME_TEST_SUITE_BEGIN(parameterTest)
// Multiple sections + charset specified and encoding
parameterizedHeaderField p4;
- p4.parse("X; param1*0*=charset'language'value1a%20;"
- " param1*1*=value1b%20;"
- " param1*2=value1c");
+ p4.parse(
+ "X; param1*0*=charset'language'value1a%20;"
+ " param1*1*=value1b%20;"
+ " param1*2=value1c"
+ );
VASSERT_EQ("4.1", 1, p4.getParameterCount());
VASSERT_EQ("4.2", "param1", PARAM_NAME(p4, 0));
@@ -270,8 +281,8 @@ VMIME_TEST_SUITE_BEGIN(parameterTest)
VASSERT_EQ("6.5", "This is ***fun***", PARAM_BUFFER(p6, 0));
}
- void testGenerate()
- {
+ void testGenerate() {
+
// Simple parameter/value
parameterizedHeaderField p1;
p1.appendParameter(vmime::make_shared <vmime::parameter>("param1", "value1"));
@@ -291,8 +302,8 @@ VMIME_TEST_SUITE_BEGIN(parameterTest)
VASSERT_EQ("2b", "F: X; param1=\"va\\\\lue\\\"1\"", p2b.generate());
}
- void testGetGeneratedSize()
- {
+ void testGetGeneratedSize() {
+
vmime::generationContext ctx(vmime::generationContext::getDefaultContext());
vmime::parameter p1("param1", "value1");
@@ -305,40 +316,70 @@ VMIME_TEST_SUITE_BEGIN(parameterTest)
VASSERT("1", p2b.getGeneratedSize(ctx) >= generateParameter(p2b, ctx).length());
}
- void testGenerateRFC2231()
- {
+ void testGenerateRFC2231() {
+
// Extended parameter with charset specifier
parameterizedHeaderField p1;
- p1.appendParameter(vmime::make_shared <vmime::parameter>("param1",
- vmime::word("value 1\xe9", vmime::charset("charset"))));
+ p1.appendParameter(
+ vmime::make_shared <vmime::parameter>(
+ "param1",
+ vmime::word("value 1\xe9", vmime::charset("charset"))
+ )
+ );
- VASSERT_EQ("1.no-encoding", "F: X; param1=\"value 1\"",
- p1.generate(vmime::generationContext::PARAMETER_VALUE_NO_ENCODING));
+ VASSERT_EQ(
+ "1.no-encoding",
+ "F: X; param1=\"value 1\"",
+ p1.generate(vmime::generationContext::PARAMETER_VALUE_NO_ENCODING)
+ );
- VASSERT_EQ("1.rfc2047", "F: X; param1=\"=?charset?Q?value_1=E9?=\"",
- p1.generate(vmime::generationContext::PARAMETER_VALUE_RFC2047_ONLY));
+ VASSERT_EQ(
+ "1.rfc2047",
+ "F: X; param1=\"=?charset?Q?value_1=E9?=\"",
+ p1.generate(vmime::generationContext::PARAMETER_VALUE_RFC2047_ONLY)
+ );
- VASSERT_EQ("1.rfc2231", "F: X; param1*=charset''value%201%E9",
- p1.generate(vmime::generationContext::PARAMETER_VALUE_RFC2231_ONLY));
+ VASSERT_EQ(
+ "1.rfc2231",
+ "F: X; param1*=charset''value%201%E9",
+ p1.generate(vmime::generationContext::PARAMETER_VALUE_RFC2231_ONLY)
+ );
- VASSERT_EQ("1.both", "F: X; param1=\"=?charset?Q?value_1=E9?=\";param1*=charset''value%201%E9",
- p1.generate(vmime::generationContext::PARAMETER_VALUE_RFC2231_AND_RFC2047));
+ VASSERT_EQ(
+ "1.both",
+ "F: X; param1=\"=?charset?Q?value_1=E9?=\";param1*=charset''value%201%E9",
+ p1.generate(vmime::generationContext::PARAMETER_VALUE_RFC2231_AND_RFC2047)
+ );
// Value that spans on multiple lines
parameterizedHeaderField p2;
- p2.appendParameter(vmime::make_shared <vmime::parameter>("param1",
- vmime::word("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
- vmime::charset("charset"))));
+ p2.appendParameter(
+ vmime::make_shared <vmime::parameter>(
+ "param1",
+ vmime::word(
+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
+ vmime::charset("charset")
+ )
+ )
+ );
- VASSERT_EQ("2.no-encoding", "F: X; \r\n "
+ VASSERT_EQ(
+ "2.no-encoding",
+ "F: X; \r\n "
"param1=abcdefghijkl",
- p2.generate(vmime::generationContext::PARAMETER_VALUE_NO_ENCODING, 25)); // max line length = 25
+ p2.generate(vmime::generationContext::PARAMETER_VALUE_NO_ENCODING, 25) // max line length = 25
+ );
- VASSERT_EQ("2.rfc2047", "F: X; \r\n "
+ VASSERT_EQ(
+ "2.rfc2047",
+ "F: X; \r\n "
"param1=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
- p2.generate(vmime::generationContext::PARAMETER_VALUE_RFC2047_ONLY, 25)); // max line length = 25
+ p2.generate(vmime::generationContext::PARAMETER_VALUE_RFC2047_ONLY, 25) // max line length = 25
+ );
- VASSERT_EQ("2.rfc2231", "F: X; \r\n "
+ VASSERT_EQ(
+ "2.rfc2231",
+ "F: X; \r\n "
"param1*0*=charset''abc;\r\n "
"param1*1*=defghijkl;\r\n "
"param1*2*=mnopqrstu;\r\n "
@@ -346,9 +387,12 @@ VMIME_TEST_SUITE_BEGIN(parameterTest)
"param1*4*=EFGHIJKLM;\r\n "
"param1*5*=NOPQRSTUV;\r\n "
"param1*6*=WXYZ",
- p2.generate(vmime::generationContext::PARAMETER_VALUE_RFC2231_ONLY, 25)); // max line length = 25
+ p2.generate(vmime::generationContext::PARAMETER_VALUE_RFC2231_ONLY, 25) // max line length = 25
+ );
- VASSERT_EQ("2.both", "F: X; \r\n "
+ VASSERT_EQ(
+ "2.both",
+ "F: X; \r\n "
"param1=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ;\r\n "
"param1*0*=charset''abc;\r\n "
"param1*1*=defghijkl;\r\n "
@@ -357,26 +401,41 @@ VMIME_TEST_SUITE_BEGIN(parameterTest)
"param1*4*=EFGHIJKLM;\r\n "
"param1*5*=NOPQRSTUV;\r\n "
"param1*6*=WXYZ",
- p2.generate(vmime::generationContext::PARAMETER_VALUE_RFC2231_AND_RFC2047, 25)); // max line length = 25
+ p2.generate(vmime::generationContext::PARAMETER_VALUE_RFC2231_AND_RFC2047, 25) // max line length = 25
+ );
// Non-ASCII parameter value
parameterizedHeaderField p3;
- p3.appendParameter(vmime::make_shared <vmime::parameter>("param1",
- vmime::word("δσσσσσσσσσσσσσσσσσσσσδσδα δσαδσδσαδσαδασδασ δσαδασδσα δσαδασδσα δασδασδασ δασαχφδδσα 2008.doc",
- vmime::charset("utf-8"))));
+ p3.appendParameter(
+ vmime::make_shared <vmime::parameter>(
+ "param1",
+ vmime::word(
+ "δσσσσσσσσσσσσσσσσσσσσδσδα δσαδσδσαδσαδασδασ δσαδασδσα δσαδασδσα δασδασδασ δασαχφδδσα 2008.doc",
+ vmime::charset("utf-8")
+ )
+ )
+ );
- VASSERT_EQ("3.no-encoding", "F: X; \r\n "
+ VASSERT_EQ(
+ "3.no-encoding",
+ "F: X; \r\n "
"param1=\" 2008.doc\"",
- p3.generate(vmime::generationContext::PARAMETER_VALUE_NO_ENCODING, 80)); // max line length = 80
+ p3.generate(vmime::generationContext::PARAMETER_VALUE_NO_ENCODING, 80) // max line length = 80
+ );
- VASSERT_EQ("3.7bit-only", "F: X; \r\n "
+ VASSERT_EQ(
+ "3.7bit-only",
+ "F: X; \r\n "
"param1=\"=?utf-8?B?zrTPg8+Dz4PPg8+Dz4PPg8+Dz4PPg8+Dz4PPg8+Dz4PPg8+Dz4PPg8+DzrTPg860?=\r\n "
"=?utf-8?B?zrEgzrTPg86xzrTPg860z4POsc60z4POsc60zrHPg860zrHPgyDOtM+DzrHOtM6x?=\r\n "
"=?utf-8?B?z4POtM+DzrEgzrTPg86xzrTOsc+DzrTPg86xIM60zrHPg860zrHPg860zrHPgyDOtA==?=\r\n "
"=?utf-8?B?zrHPg86xz4fPhs60zrTPg86xIDIwMDguZG9j?=\"",
- p3.generate(vmime::generationContext::PARAMETER_VALUE_RFC2047_ONLY, 80)); // max line length = 80
+ p3.generate(vmime::generationContext::PARAMETER_VALUE_RFC2047_ONLY, 80) // max line length = 80
+ );
- VASSERT_EQ("3.both", "F: X; \r\n "
+ VASSERT_EQ(
+ "3.both",
+ "F: X; \r\n "
"param1=\"=?utf-8?B?zrTPg8+Dz4PPg8+Dz4PPg8+Dz4PPg8+Dz4PPg8+Dz4PPg8+Dz4PPg8+DzrTPg860?=\r\n "
"=?utf-8?B?zrEgzrTPg86xzrTPg860z4POsc60z4POsc60zrHPg860zrHPgyDOtM+DzrHOtM6x?=\r\n "
"=?utf-8?B?z4POtM+DzrEgzrTPg86xzrTOsc+DzrTPg86xIM60zrHPg860zrHPg860zrHPgyDOtA==?=\r\n "
@@ -389,9 +448,12 @@ VMIME_TEST_SUITE_BEGIN(parameterTest)
"param1*5*=%83%CE%B1%CE%B4%CE%B1%CF%83%CE%B4%CF%83%CE%B1%20%CE%B4%CE%B1%CF%83;\r\n "
"param1*6*=%CE%B4%CE%B1%CF%83%CE%B4%CE%B1%CF%83%20%CE%B4%CE%B1%CF%83%CE%B1%CF;\r\n "
"param1*7*=%87%CF%86%CE%B4%CE%B4%CF%83%CE%B1%202008.doc",
- p3.generate(vmime::generationContext::PARAMETER_VALUE_RFC2231_AND_RFC2047, 80)); // max line length = 80
+ p3.generate(vmime::generationContext::PARAMETER_VALUE_RFC2231_AND_RFC2047, 80) // max line length = 80
+ );
- VASSERT_EQ("3.either", "F: X; param1*0*=utf-8''%CE%B4%CF%83%CF%83%CF%83%CF%83%CF%83%CF%83%CF%83%CF%83%CF%83;\r\n "
+ VASSERT_EQ(
+ "3.either",
+ "F: X; param1*0*=utf-8''%CE%B4%CF%83%CF%83%CF%83%CF%83%CF%83%CF%83%CF%83%CF%83%CF%83;\r\n "
"param1*1*=%CF%83%CF%83%CF%83%CF%83%CF%83%CF%83%CF%83%CF%83%CF%83%CF%83%CF%83;\r\n "
"param1*2*=%CE%B4%CF%83%CE%B4%CE%B1%20%CE%B4%CF%83%CE%B1%CE%B4%CF%83%CE%B4%CF;\r\n "
"param1*3*=%83%CE%B1%CE%B4%CF%83%CE%B1%CE%B4%CE%B1%CF%83%CE%B4%CE%B1%CF%83%20;\r\n "
@@ -399,47 +461,77 @@ VMIME_TEST_SUITE_BEGIN(parameterTest)
"param1*5*=%83%CE%B1%CE%B4%CE%B1%CF%83%CE%B4%CF%83%CE%B1%20%CE%B4%CE%B1%CF%83;\r\n "
"param1*6*=%CE%B4%CE%B1%CF%83%CE%B4%CE%B1%CF%83%20%CE%B4%CE%B1%CF%83%CE%B1%CF;\r\n "
"param1*7*=%87%CF%86%CE%B4%CE%B4%CF%83%CE%B1%202008.doc",
- p3.generate(vmime::generationContext::PARAMETER_VALUE_RFC2231_ONLY, 80)); // max line length = 80
+ p3.generate(vmime::generationContext::PARAMETER_VALUE_RFC2231_ONLY, 80) // max line length = 80
+ );
// No encoding needed
parameterizedHeaderField p4;
- p4.appendParameter(vmime::make_shared <vmime::parameter>("param1",
- vmime::word("va lue", vmime::charset("charset"))));
+ p4.appendParameter(
+ vmime::make_shared <vmime::parameter>(
+ "param1",
+ vmime::word("va lue", vmime::charset("charset"))
+ )
+ );
- VASSERT_EQ("4.no-encoding", "F: X; param1=\"va lue\"",
- p4.generate(vmime::generationContext::PARAMETER_VALUE_NO_ENCODING));
+ VASSERT_EQ(
+ "4.no-encoding",
+ "F: X; param1=\"va lue\"",
+ p4.generate(vmime::generationContext::PARAMETER_VALUE_NO_ENCODING)
+ );
- VASSERT_EQ("4.rfc2047", "F: X; param1=\"va lue\"",
- p4.generate(vmime::generationContext::PARAMETER_VALUE_RFC2047_ONLY));
+ VASSERT_EQ(
+ "4.rfc2047",
+ "F: X; param1=\"va lue\"",
+ p4.generate(vmime::generationContext::PARAMETER_VALUE_RFC2047_ONLY)
+ );
- VASSERT_EQ("4.rfc2231", "F: X; param1=\"va lue\"",
- p4.generate(vmime::generationContext::PARAMETER_VALUE_RFC2231_ONLY));
+ VASSERT_EQ(
+ "4.rfc2231",
+ "F: X; param1=\"va lue\"",
+ p4.generate(vmime::generationContext::PARAMETER_VALUE_RFC2231_ONLY)
+ );
- VASSERT_EQ("4.both", "F: X; param1=\"va lue\"",
- p4.generate(vmime::generationContext::PARAMETER_VALUE_RFC2231_AND_RFC2047));
+ VASSERT_EQ(
+ "4.both",
+ "F: X; param1=\"va lue\"",
+ p4.generate(vmime::generationContext::PARAMETER_VALUE_RFC2231_AND_RFC2047)
+ );
// Language specification
parameterizedHeaderField p5;
- p5.appendParameter(vmime::make_shared <vmime::parameter>("param1",
- vmime::word("This is ***fun***", vmime::charset("us-ascii"), "en-us")));
+ p5.appendParameter(
+ vmime::make_shared <vmime::parameter>("param1",
+ vmime::word("This is ***fun***", vmime::charset("us-ascii"), "en-us"))
+ );
- VASSERT_EQ("5.no-encoding", "F: X; param1=\"This is ***fun***\"",
- p5.generate(vmime::generationContext::PARAMETER_VALUE_NO_ENCODING));
+ VASSERT_EQ(
+ "5.no-encoding",
+ "F: X; param1=\"This is ***fun***\"",
+ p5.generate(vmime::generationContext::PARAMETER_VALUE_NO_ENCODING)
+ );
- VASSERT_EQ("5.rfc2047", "F: X; param1=\"=?us-ascii*en-us?Q?This_is_***fun***?=\"",
- p5.generate(vmime::generationContext::PARAMETER_VALUE_RFC2047_ONLY));
+ VASSERT_EQ(
+ "5.rfc2047",
+ "F: X; param1=\"=?us-ascii*en-us?Q?This_is_***fun***?=\"",
+ p5.generate(vmime::generationContext::PARAMETER_VALUE_RFC2047_ONLY)
+ );
- VASSERT_EQ("5.rfc2231", "F: X; param1*=us-ascii''This%20is%20***fun***",
- p5.generate(vmime::generationContext::PARAMETER_VALUE_RFC2231_ONLY));
+ VASSERT_EQ(
+ "5.rfc2231",
+ "F: X; param1*=us-ascii''This%20is%20***fun***",
+ p5.generate(vmime::generationContext::PARAMETER_VALUE_RFC2231_ONLY)
+ );
- VASSERT_EQ("5.both", "F: X; "
- "param1=\"=?us-ascii*en-us?Q?This_is_***fun***?=\";\r\n "
- "param1*=us-ascii''This%20is%20***fun***",
+ VASSERT_EQ(
+ "5.both",
+ "F: X; "
+ "param1=\"=?us-ascii*en-us?Q?This_is_***fun***?=\";\r\n "
+ "param1*=us-ascii''This%20is%20***fun***",
p5.generate(vmime::generationContext::PARAMETER_VALUE_RFC2231_AND_RFC2047));
}
- void testGetGeneratedSizeRFC2231()
- {
+ void testGetGeneratedSizeRFC2231() {
+
vmime::generationContext ctx(vmime::generationContext::getDefaultContext());
// Extended parameter with charset specifier
@@ -543,12 +635,12 @@ VMIME_TEST_SUITE_BEGIN(parameterTest)
VASSERT("5.both", p5.getGeneratedSize(ctx) >= generateParameter(p5, ctx).length());
}
- void testNonStandardEncodedParam()
- {
+ void testNonStandardEncodedParam() {
+
// This syntax is non-standard (expressly prohibited
// by RFC-2047), but is used by Mozilla:
//
- // Content-Type: image/png;
+ // Content-Type: image/png;
// name="=?us-ascii?Q?Logo_VMime=2Epng?="
parameterizedHeaderField p1;
@@ -567,8 +659,8 @@ VMIME_TEST_SUITE_BEGIN(parameterTest)
}
// Parse parameters with non-significant whitespaces
- void testParseNonSignificantWS()
- {
+ void testParseNonSignificantWS() {
+
parameterizedHeaderField p1;
p1.parse(" \t X \r\n");
@@ -584,8 +676,8 @@ VMIME_TEST_SUITE_BEGIN(parameterTest)
}
// Encode "tspecials"
- void testEncodeTSpecials()
- {
+ void testEncodeTSpecials() {
+
VASSERT_EQ(" 1", "p=\"val(ue\"", vmime::make_shared <vmime::parameter>("p", "val(ue")->generate());
VASSERT_EQ(" 2", "p=\"val)ue\"", vmime::make_shared <vmime::parameter>("p", "val)ue")->generate());
VASSERT_EQ(" 3", "p=\"val<ue\"", vmime::make_shared <vmime::parameter>("p", "val<ue")->generate());
@@ -604,16 +696,20 @@ VMIME_TEST_SUITE_BEGIN(parameterTest)
}
// http://sourceforge.net/projects/vmime/forums/forum/237356/topic/3812278
- void testEncodeTSpecialsInRFC2231()
- {
- VASSERT_EQ("1", "filename*=UTF-8''my_file_name_%C3%B6%C3%A4%C3%BC_%281%29.txt",
- vmime::make_shared <vmime::parameter>
- ("filename",
- vmime::word("my_file_name_\xc3\xb6\xc3\xa4\xc3\xbc_(1).txt", "UTF-8"))->generate());
+ void testEncodeTSpecialsInRFC2231() {
+
+ VASSERT_EQ(
+ "1",
+ "filename*=UTF-8''my_file_name_%C3%B6%C3%A4%C3%BC_%281%29.txt",
+ vmime::make_shared <vmime::parameter>(
+ "filename",
+ vmime::word("my_file_name_\xc3\xb6\xc3\xa4\xc3\xbc_(1).txt", "UTF-8")
+ )->generate()
+ );
}
- void testWhitespaceBreaksTheValue()
- {
+ void testWhitespaceBreaksTheValue() {
+
parameterizedHeaderField p;
p.parse("xxx yyy; param1=value1 \r\n");
@@ -624,4 +720,3 @@ VMIME_TEST_SUITE_BEGIN(parameterTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/parser/pathTest.cpp b/tests/parser/pathTest.cpp
index f73dd0d4..13969112 100644
--- a/tests/parser/pathTest.cpp
+++ b/tests/parser/pathTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -33,8 +33,8 @@ VMIME_TEST_SUITE_BEGIN(pathTest)
VMIME_TEST_LIST_END
- void testParse()
- {
+ void testParse() {
+
vmime::path p1;
p1.parse("<>");
@@ -54,8 +54,8 @@ VMIME_TEST_SUITE_BEGIN(pathTest)
VASSERT_EQ("3.2", "domain", p3.getDomain());
}
- void testParse2()
- {
+ void testParse2() {
+
// Test some invalid paths (no '<>')
vmime::path p1;
p1.parse("");
@@ -76,8 +76,8 @@ VMIME_TEST_SUITE_BEGIN(pathTest)
VASSERT_EQ("3.2", "domain", p3.getDomain());
}
- void testGenerate()
- {
+ void testGenerate() {
+
vmime::path p1;
VASSERT_EQ("1", "<>", p1.generate());
@@ -100,4 +100,3 @@ VMIME_TEST_SUITE_BEGIN(pathTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/parser/streamContentHandlerTest.cpp b/tests/parser/streamContentHandlerTest.cpp
index 55680c93..399118e7 100644
--- a/tests/parser/streamContentHandlerTest.cpp
+++ b/tests/parser/streamContentHandlerTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -41,15 +41,15 @@ VMIME_TEST_SUITE_BEGIN(streamContentHandlerTest)
VMIME_TEST_LIST_END
- void testIsEmpty()
- {
+ void testIsEmpty() {
+
vmime::streamContentHandler cth;
VASSERT_TRUE("empty", cth.isEmpty());
}
- void testGetLength()
- {
+ void testGetLength() {
+
vmime::string data("Test Data");
vmime::shared_ptr <vmime::utility::inputStream> stream =
vmime::make_shared <vmime::utility::inputStreamStringAdapter>(data);
@@ -60,8 +60,8 @@ VMIME_TEST_SUITE_BEGIN(streamContentHandlerTest)
VASSERT_EQ("length", 9, cth.getLength());
}
- void testIsEncoded()
- {
+ void testIsEncoded() {
+
vmime::string data("Test Data");
vmime::shared_ptr <vmime::utility::inputStream> stream =
vmime::make_shared <vmime::utility::inputStreamStringAdapter>(data);
@@ -82,8 +82,8 @@ VMIME_TEST_SUITE_BEGIN(streamContentHandlerTest)
VASSERT_EQ("encoding", "base64", cth2.getEncoding().generate());
}
- void testGetLength_Encoded()
- {
+ void testGetLength_Encoded() {
+
vmime::string data("foo=12=34=56bar");
vmime::shared_ptr <vmime::utility::inputStream> stream =
vmime::make_shared <vmime::utility::inputStreamStringAdapter>(data);
@@ -94,8 +94,8 @@ VMIME_TEST_SUITE_BEGIN(streamContentHandlerTest)
VASSERT_EQ("length", 15, cth.getLength());
}
- void testExtract()
- {
+ void testExtract() {
+
vmime::string data("Test Data");
vmime::shared_ptr <vmime::utility::inputStream> stream =
vmime::make_shared <vmime::utility::inputStreamStringAdapter>(data);
@@ -110,10 +110,12 @@ VMIME_TEST_SUITE_BEGIN(streamContentHandlerTest)
VASSERT_EQ("extract", "Test Data", oss.str());
}
- void testExtract_Encoded()
- {
- vmime::string data
- ("QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODk=");
+ void testExtract_Encoded() {
+
+ vmime::string data(
+ "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODk="
+ );
+
vmime::shared_ptr <vmime::utility::inputStream> stream =
vmime::make_shared <vmime::utility::inputStreamStringAdapter>(data);
@@ -125,14 +127,18 @@ VMIME_TEST_SUITE_BEGIN(streamContentHandlerTest)
cth.extract(osa);
// Data should be decoded from B64
- VASSERT_EQ("extract",
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", oss.str());
+ VASSERT_EQ(
+ "extract",
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
+ oss.str()
+ );
}
void testExtractRaw_Encoded()
{
- vmime::string data
- ("QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODk=");
+ vmime::string data(
+ "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODk="
+ );
vmime::shared_ptr <vmime::utility::inputStream> stream =
vmime::make_shared <vmime::utility::inputStreamStringAdapter>(data);
@@ -144,12 +150,15 @@ VMIME_TEST_SUITE_BEGIN(streamContentHandlerTest)
cth.extractRaw(osa);
// Data should not be decoded
- VASSERT_EQ("extractRaw",
- "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODk=", oss.str());
+ VASSERT_EQ(
+ "extractRaw",
+ "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODk=",
+ oss.str()
+ );
}
- void testGenerate()
- {
+ void testGenerate() {
+
vmime::string data("foo\x12\x34\x56 bar");
vmime::shared_ptr <vmime::utility::inputStream> stream =
vmime::make_shared <vmime::utility::inputStreamStringAdapter>(data);
@@ -165,8 +174,8 @@ VMIME_TEST_SUITE_BEGIN(streamContentHandlerTest)
VASSERT_EQ("generate", "Zm9vEjRWIGJhcg==", oss.str());
}
- void testGenerate_Encoded()
- {
+ void testGenerate_Encoded() {
+
vmime::string data("foo=12=34=56bar");
vmime::shared_ptr <vmime::utility::inputStream> stream =
vmime::make_shared <vmime::utility::inputStreamStringAdapter>(data);
diff --git a/tests/parser/stringContentHandlerTest.cpp b/tests/parser/stringContentHandlerTest.cpp
index e238e172..0f886f76 100644
--- a/tests/parser/stringContentHandlerTest.cpp
+++ b/tests/parser/stringContentHandlerTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -42,23 +42,23 @@ VMIME_TEST_SUITE_BEGIN(stringContentHandlerTest)
VMIME_TEST_LIST_END
- void testIsEmpty()
- {
+ void testIsEmpty() {
+
vmime::stringContentHandler cth;
VASSERT_TRUE("empty", cth.isEmpty());
}
- void testGetLength()
- {
+ void testGetLength() {
+
vmime::stringContentHandler cth("Test Data");
VASSERT_FALSE("empty", cth.isEmpty());
VASSERT_EQ("length", 9, cth.getLength());
}
- void testIsEncoded()
- {
+ void testIsEncoded() {
+
vmime::stringContentHandler cth("Test Data");
VASSERT_FALSE("encoded", cth.isEncoded());
@@ -71,17 +71,19 @@ VMIME_TEST_SUITE_BEGIN(stringContentHandlerTest)
VASSERT_EQ("encoding", "base64", cth2.getEncoding().generate());
}
- void testGetLength_Encoded()
- {
- vmime::stringContentHandler cth
- ("foo=12=34=56bar", vmime::encoding("quoted-printable"));
+ void testGetLength_Encoded() {
+
+ vmime::stringContentHandler cth(
+ "foo=12=34=56bar",
+ vmime::encoding("quoted-printable")
+ );
// Reported length should be the length of encoded data
VASSERT_EQ("length", 15, cth.getLength());
}
- void testExtract()
- {
+ void testExtract() {
+
vmime::stringContentHandler cth("Test Data");
std::ostringstream oss;
@@ -92,11 +94,12 @@ VMIME_TEST_SUITE_BEGIN(stringContentHandlerTest)
VASSERT_EQ("extract", "Test Data", oss.str());
}
- void testExtract_Encoded()
- {
- vmime::stringContentHandler cth
- ("QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODk=",
- vmime::encoding("base64"));
+ void testExtract_Encoded() {
+
+ vmime::stringContentHandler cth(
+ "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODk=",
+ vmime::encoding("base64")
+ );
std::ostringstream oss;
vmime::utility::outputStreamAdapter osa(oss);
@@ -104,15 +107,19 @@ VMIME_TEST_SUITE_BEGIN(stringContentHandlerTest)
cth.extract(osa);
// Data should be decoded from B64
- VASSERT_EQ("extract",
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", oss.str());
+ VASSERT_EQ(
+ "extract",
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
+ oss.str()
+ );
}
- void testExtractRaw_Encoded()
- {
- vmime::stringContentHandler cth
- ("QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODk=",
- vmime::encoding("base64"));
+ void testExtractRaw_Encoded() {
+
+ vmime::stringContentHandler cth(
+ "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODk=",
+ vmime::encoding("base64")
+ );
std::ostringstream oss;
vmime::utility::outputStreamAdapter osa(oss);
@@ -120,12 +127,15 @@ VMIME_TEST_SUITE_BEGIN(stringContentHandlerTest)
cth.extractRaw(osa);
// Data should not be decoded
- VASSERT_EQ("extractRaw",
- "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODk=", oss.str());
+ VASSERT_EQ(
+ "extractRaw",
+ "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODk=",
+ oss.str()
+ );
}
- void testGenerate()
- {
+ void testGenerate() {
+
vmime::stringContentHandler cth("foo\x12\x34\x56 bar");
std::ostringstream oss;
@@ -137,10 +147,12 @@ VMIME_TEST_SUITE_BEGIN(stringContentHandlerTest)
VASSERT_EQ("generate", "Zm9vEjRWIGJhcg==", oss.str());
}
- void testGenerate_Encoded()
- {
- vmime::stringContentHandler cth
- ("foo=12=34=56bar", vmime::encoding("quoted-printable"));
+ void testGenerate_Encoded() {
+
+ vmime::stringContentHandler cth(
+ "foo=12=34=56bar",
+ vmime::encoding("quoted-printable")
+ );
std::ostringstream oss;
vmime::utility::outputStreamAdapter osa(oss);
@@ -151,8 +163,8 @@ VMIME_TEST_SUITE_BEGIN(stringContentHandlerTest)
VASSERT_EQ("generate", "Zm9vEjRWYmFy", oss.str());
}
- void testStringProxy()
- {
+ void testStringProxy() {
+
// With 'stringProxy' object
vmime::utility::stringProxy str("This is the data buffer", 12, 12 + 4);
vmime::stringContentHandler cth(str);
diff --git a/tests/parser/textTest.cpp b/tests/parser/textTest.cpp
index 60a9508e..16abf11b 100644
--- a/tests/parser/textTest.cpp
+++ b/tests/parser/textTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -66,48 +66,46 @@ VMIME_TEST_SUITE_BEGIN(textTest)
VMIME_TEST_LIST_END
- static const vmime::string getDisplayText(const vmime::text& t)
- {
+ static const vmime::string getDisplayText(const vmime::text& t) {
+
return t.getWholeBuffer();
}
- static const vmime::string cleanGeneratedWords(const std::string& str)
- {
+ static const vmime::string cleanGeneratedWords(const std::string& str) {
+
std::istringstream iss(str);
std::string res;
std::string x;
- while (std::getline(iss, x))
+ while (std::getline(iss, x)) {
res += vmime::utility::stringUtils::trim(x);
+ }
return res;
}
- void setUp()
- {
+ void setUp() {
+
// Set the global C and C++ locale to the user-configured locale.
// The locale should use UTF-8 encoding for these tests to run successfully.
- try
- {
+ try {
std::locale::global(std::locale(""));
- }
- catch (std::exception &)
- {
+ } catch (std::exception &) {
std::setlocale(LC_ALL, "");
}
}
- void tearDown()
- {
+ void tearDown() {
+
// Restore default locale
std::locale::global(std::locale("C"));
}
- void testConstructors()
- {
+ void testConstructors() {
+
vmime::text t1;
VASSERT_EQ("1.1", 0, t1.getWordCount());
@@ -143,8 +141,8 @@ VMIME_TEST_SUITE_BEGIN(textTest)
VASSERT_EQ("5.5", w2.getCharset(), t5.getWordAt(1)->getCharset());
}
- void testCopy()
- {
+ void testCopy() {
+
vmime::text t1("Test: \xa9\xc3");
VASSERT("operator==", t1 == t1);
@@ -156,8 +154,8 @@ VMIME_TEST_SUITE_BEGIN(textTest)
VASSERT("copyFrom", t1 == t2);
}
- void testNewFromString()
- {
+ void testNewFromString() {
+
vmime::string s1 = "only ASCII characters";
vmime::charset c1("test");
vmime::text t1;
@@ -186,52 +184,75 @@ VMIME_TEST_SUITE_BEGIN(textTest)
VASSERT_EQ("2.7", vmime::charset(vmime::charsets::US_ASCII), t2.getWordAt(2)->getCharset());
}
- static const vmime::string parseText(const vmime::string& buffer)
- {
+ static const vmime::string parseText(const vmime::string& buffer) {
+
vmime::text t;
t.parse(buffer);
std::ostringstream oss;
oss << t;
- return (oss.str());
+ return oss.str();
}
- void testParse()
- {
+ void testParse() {
+
// From RFC-2047
- VASSERT_EQ("1", "[text: [[word: charset=US-ASCII, buffer=Keith Moore]]]",
- parseText("=?US-ASCII?Q?Keith_Moore?="));
+ VASSERT_EQ(
+ "1",
+ "[text: [[word: charset=US-ASCII, buffer=Keith Moore]]]",
+ parseText("=?US-ASCII?Q?Keith_Moore?=")
+ );
- VASSERT_EQ("2", "[text: [[word: charset=ISO-8859-1, buffer=Keld J\xf8rn Simonsen]]]",
- parseText("=?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?="));
+ VASSERT_EQ(
+ "2",
+ "[text: [[word: charset=ISO-8859-1, buffer=Keld J\xf8rn Simonsen]]]",
+ parseText("=?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?=")
+ );
- VASSERT_EQ("3", "[text: [[word: charset=ISO-8859-1, buffer=Andr\xe9]," \
- "[word: charset=us-ascii, buffer= Pirard]]]",
- parseText("=?ISO-8859-1?Q?Andr=E9?= Pirard"));
+ VASSERT_EQ(
+ "3",
+ "[text: [[word: charset=ISO-8859-1, buffer=Andr\xe9]," \
+ "[word: charset=us-ascii, buffer= Pirard]]]",
+ parseText("=?ISO-8859-1?Q?Andr=E9?= Pirard")
+ );
- VASSERT_EQ("4", "[text: [[word: charset=ISO-8859-1, buffer=If you can read this yo]," \
- "[word: charset=ISO-8859-2, buffer=u understand the example.]]]",
- parseText("=?ISO-8859-1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW8=?=\r\n " \
- "=?ISO-8859-2?B?dSB1bmRlcnN0YW5kIHRoZSBleGFtcGxlLg==?="));
+ VASSERT_EQ(
+ "4",
+ "[text: [[word: charset=ISO-8859-1, buffer=If you can read this yo]," \
+ "[word: charset=ISO-8859-2, buffer=u understand the example.]]]",
+ parseText(
+ "=?ISO-8859-1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW8=?=\r\n " \
+ "=?ISO-8859-2?B?dSB1bmRlcnN0YW5kIHRoZSBleGFtcGxlLg==?="
+ )
+ );
// Bugfix: in "=?charset?q?=XX=YY?=", the "?=" finish
// sequence was not correctly found (should be the one
// after '=YY' and not the one after '?q').
- VASSERT_EQ("5", "[text: [[word: charset=abc, buffer=\xe9\xe9]]]",
- parseText("=?abc?q?=E9=E9?="));
+ VASSERT_EQ(
+ "5",
+ "[text: [[word: charset=abc, buffer=\xe9\xe9]]]",
+ parseText("=?abc?q?=E9=E9?=")
+ );
// Question marks (?) in the middle of the string
- VASSERT_EQ("6", "[text: [[word: charset=iso-8859-1, buffer=Know wh\xe4t? It works!]]]",
- parseText("=?iso-8859-1?Q?Know_wh=E4t?_It_works!?="));
+ VASSERT_EQ(
+ "6",
+ "[text: [[word: charset=iso-8859-1, buffer=Know wh\xe4t? It works!]]]",
+ parseText("=?iso-8859-1?Q?Know_wh=E4t?_It_works!?=")
+ );
// With language specifier
- VASSERT_EQ("7", "[text: [[word: charset=US-ASCII, buffer=Keith Moore, lang=EN]]]",
- parseText("=?US-ASCII*EN?Q?Keith_Moore?="));
+ VASSERT_EQ(
+ "7",
+ "[text: [[word: charset=US-ASCII, buffer=Keith Moore, lang=EN]]]",
+ parseText("=?US-ASCII*EN?Q?Keith_Moore?=")
+ );
}
- void testGenerate()
- {
+ void testGenerate() {
+
// TODO
// With language specifier
@@ -242,8 +263,8 @@ VMIME_TEST_SUITE_BEGIN(textTest)
VASSERT_EQ("lang2", "=?US-ASCII*EN?Q?Keith_Moore?=", wlang2.generate());
}
- void testDisplayForm()
- {
+ void testDisplayForm() {
+
#define DISPLAY_FORM(x) getDisplayText(*vmime::text::decodeAndUnfold(x))
// From RFC-2047
@@ -276,8 +297,8 @@ VMIME_TEST_SUITE_BEGIN(textTest)
#undef DISPLAY_FORM
}
- void testWordConstructors()
- {
+ void testWordConstructors() {
+
VASSERT_EQ("1.1", vmime::charset::getLocalCharset(), vmime::word().getCharset());
VASSERT_EQ("1.2", "", vmime::word().getBuffer());
@@ -288,8 +309,8 @@ VMIME_TEST_SUITE_BEGIN(textTest)
VASSERT_EQ("3.2", "foo", vmime::word("foo", vmime::charset("bar")).getBuffer());
}
- void testWordParse()
- {
+ void testWordParse() {
+
// Simple encoded word
vmime::word w1;
w1.parse("=?foo?q?bar=E9 baz?=");
@@ -319,21 +340,32 @@ VMIME_TEST_SUITE_BEGIN(textTest)
VASSERT_EQ("4.2", "=?whatever?not_q_or_b?whatever?=", w4.getBuffer());
}
- void testWordGenerate()
- {
- VASSERT_EQ("1", "=?foo?Q?bar=E9_baz?=",
- vmime::word("bar\xe9 baz", vmime::charset("foo")).generate());
+ void testWordGenerate() {
- VASSERT_EQ("2", "=?foo?B?8fLz9PU=?=",
- vmime::word("\xf1\xf2\xf3\xf4\xf5", vmime::charset("foo")).generate());
+ VASSERT_EQ(
+ "1",
+ "=?foo?Q?bar=E9_baz?=",
+ vmime::word("bar\xe9 baz", vmime::charset("foo")).generate()
+ );
+
+ VASSERT_EQ(
+ "2",
+ "=?foo?B?8fLz9PU=?=",
+ vmime::word("\xf1\xf2\xf3\xf4\xf5", vmime::charset("foo")).generate()
+ );
}
- void testWordGenerateSpace()
- {
+ void testWordGenerateSpace() {
+
// No white-space between an unencoded word and a encoded one
- VASSERT_EQ("1", "Bonjour =?utf-8?Q?Fran=C3=A7ois?=",
- vmime::text::newFromString("Bonjour Fran\xc3\xa7ois",
- vmime::charset("utf-8"))->generate());
+ VASSERT_EQ(
+ "1",
+ "Bonjour =?utf-8?Q?Fran=C3=A7ois?=",
+ vmime::text::newFromString(
+ "Bonjour Fran\xc3\xa7ois",
+ vmime::charset("utf-8")
+ )->generate()
+ );
// White-space between two encoded words
vmime::text txt;
@@ -356,8 +388,8 @@ VMIME_TEST_SUITE_BEGIN(textTest)
VASSERT_EQ("4", encoded, txt2.generate());
}
- void testWordGenerateSpace2()
- {
+ void testWordGenerateSpace2() {
+
// White-space between two encoded words (#2)
vmime::text txt;
txt.appendWord(vmime::make_shared <vmime::word>("Facture ", "utf-8"));
@@ -382,18 +414,28 @@ VMIME_TEST_SUITE_BEGIN(textTest)
VASSERT_EQ("3", encoded, txt2.generate());
}
- void testWordGenerateMultiBytes()
- {
+ 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?==?utf-8?Q?=C3=A9?==?utf-8?Q?zzz?=",
+ cleanGeneratedWords(
+ vmime::word("aaa\xc3\xa9zzz", vmime::charset("utf-8")).generate(16)
+ )
+ );
- VASSERT_EQ("2", "=?utf-8?Q?aaa=C3=A9?==?utf-8?Q?zzz?=",
- cleanGeneratedWords(vmime::word("aaa\xc3\xa9zzz", vmime::charset("utf-8")).generate(17)));
+ VASSERT_EQ(
+ "2",
+ "=?utf-8?Q?aaa=C3=A9?==?utf-8?Q?zzz?=",
+ cleanGeneratedWords(
+ vmime::word("aaa\xc3\xa9zzz", vmime::charset("utf-8")).generate(17)
+ )
+ );
}
- void testWordGenerateQuote()
- {
+ void testWordGenerateQuote() {
+
std::string str;
vmime::utility::outputStreamStringAdapter os(str);
@@ -402,37 +444,56 @@ VMIME_TEST_SUITE_BEGIN(textTest)
// ASCII-only text is quotable
str.clear();
- vmime::word("Quoted text").generate(ctx, os, 0, NULL, vmime::text::QUOTE_IF_POSSIBLE, NULL);
+ vmime::word("Quoted text")
+ .generate(ctx, os, 0, NULL, vmime::text::QUOTE_IF_POSSIBLE, NULL);
+
VASSERT_EQ("1", "\"Quoted text\"", cleanGeneratedWords(str));
// Text with CR/LF is not quotable
str.clear();
- vmime::word("Non-quotable\ntext", "us-ascii").generate(ctx, os, 0, NULL, vmime::text::QUOTE_IF_POSSIBLE, NULL);
+ vmime::word("Non-quotable\ntext", "us-ascii")
+ .generate(ctx, os, 0, NULL, vmime::text::QUOTE_IF_POSSIBLE, NULL);
+
VASSERT_EQ("2", "=?us-ascii?Q?Non-quotable=0Atext?=", cleanGeneratedWords(str));
// Text with non-ASCII chars is not quotable
str.clear();
- vmime::word("Non-quotable text \xc3\xa9").generate(ctx, os, 0, NULL, vmime::text::QUOTE_IF_POSSIBLE, NULL);
+ vmime::word("Non-quotable text \xc3\xa9")
+ .generate(ctx, os, 0, NULL, vmime::text::QUOTE_IF_POSSIBLE, NULL);
+
VASSERT_EQ("3", "=?UTF-8?Q?Non-quotable_text_=C3=A9?=", cleanGeneratedWords(str));
}
- void testWordGenerateSpecialCharsets()
- {
+ void testWordGenerateSpecialCharsets() {
+
// ISO-2022-JP only uses 7-bit chars but should be encoded in Base64
- VASSERT_EQ("1", "=?iso-2022-jp?B?XlskQiVRITwlPSVKJWshJiU9JVUlSCUmJSclIl5bKEI=?=",
- cleanGeneratedWords(vmime::word("^[$B%Q!<%=%J%k!&%=%U%H%&%'%\"^[(B",
- vmime::charset("iso-2022-jp")).generate(100)));
+ VASSERT_EQ(
+ "1",
+ "=?iso-2022-jp?B?XlskQiVRITwlPSVKJWshJiU9JVUlSCUmJSclIl5bKEI=?=",
+ cleanGeneratedWords(
+ vmime::word(
+ "^[$B%Q!<%=%J%k!&%=%U%H%&%'%\"^[(B",
+ vmime::charset("iso-2022-jp")
+ ).generate(100)
+ )
+ );
}
- void testWordGenerateSpecials()
- {
+ void testWordGenerateSpecials() {
+
// In RFC-2047, quotation marks (ASCII 22h) should be encoded
- VASSERT_EQ("1", "=?UTF-8?Q?=22=C3=9Cml=C3=A4ute=22?=",
- vmime::word("\x22\xC3\x9Cml\xC3\xA4ute\x22", vmime::charset("UTF-8")).generate());
+ VASSERT_EQ(
+ "1",
+ "=?UTF-8?Q?=22=C3=9Cml=C3=A4ute=22?=",
+ vmime::word(
+ "\x22\xC3\x9Cml\xC3\xA4ute\x22",
+ vmime::charset("UTF-8")
+ ).generate()
+ );
}
- void testWhitespace()
- {
+ void testWhitespace() {
+
// Create
vmime::text text;
text.createFromString("Achim Br\xc3\xa4ndt", vmime::charsets::UTF_8);
@@ -456,8 +517,8 @@ VMIME_TEST_SUITE_BEGIN(textTest)
VASSERT_EQ("11", "utf-8", text.getWordAt(1)->getCharset());
}
- void testWhitespaceMBox()
- {
+ void testWhitespaceMBox() {
+
// Space MUST be encoded inside a word
vmime::mailbox mbox(vmime::text("Achim Br\xc3\xa4ndt", vmime::charsets::UTF_8), "[email protected]");
VASSERT_EQ("generate1", "=?us-ascii?Q?Achim_?= =?utf-8?Q?Br=C3=A4ndt?= <[email protected]>", mbox.generate());
@@ -478,30 +539,38 @@ VMIME_TEST_SUITE_BEGIN(textTest)
VASSERT_EQ("parse.email", "[email protected]", mbox.getEmail());
}
- void testFoldingAscii()
- {
+ void testFoldingAscii() {
+
// In this test, no encoding is needed, but line should be folded anyway
vmime::word w("01234567890123456789012345678901234567890123456789"
"01234567890123456789012345678901234567890123456789", vmime::charset("us-ascii"));
- VASSERT_EQ("fold.ascii",
+ VASSERT_EQ(
+ "fold.ascii",
"=?us-ascii?Q?01234567890123456789012345678901234?=\r\n"
" =?us-ascii?Q?5678901234567890123456789012345678?=\r\n"
- " =?us-ascii?Q?9012345678901234567890123456789?=", w.generate(50));
+ " =?us-ascii?Q?9012345678901234567890123456789?=", w.generate(50)
+ );
}
- void testForcedNonEncoding()
- {
+ void testForcedNonEncoding() {
+
// Testing long unbreakable and unencodable header
vmime::relay r;
- r.parse(" from User (Ee9GMqZQ8t7IQwftfAFHd2KyScCYRrFSJ50tKEoXv2bVCG4HcPU80GGWiFabAvG77FekpGgF1h@[127.0.0.1]) by servername.hostname.com\n\t"
- "with esmtp id 1NGTS9-2C0sqG0; Fri, 4 Dec 2009 09:23:49 +0100");
+ r.parse(
+ " from User (Ee9GMqZQ8t7IQwftfAFHd2KyScCYRrFSJ50tKEoXv2bVCG4HcPU80GGWiFabAvG77FekpGgF1h@[127.0.0.1]) by servername.hostname.com\n\t"
+ "with esmtp id 1NGTS9-2C0sqG0; Fri, 4 Dec 2009 09:23:49 +0100"
+ );
- VASSERT_EQ("received.long", "from User\r\n (Ee9GMqZQ8t7IQwftfAFHd2KyScCYRrFSJ50tKEoXv2bVCG4HcPU80GGWiFabAvG77FekpGgF1h@[127.0.0.1])\r\n by servername.hostname.com with esmtp id 1NGTS9-2C0sqG0; Fri, 4 Dec 2009\r\n 09:23:49 +0100", r.generate(78));
+ VASSERT_EQ(
+ "received.long",
+ "from User\r\n (Ee9GMqZQ8t7IQwftfAFHd2KyScCYRrFSJ50tKEoXv2bVCG4HcPU80GGWiFabAvG77FekpGgF1h@[127.0.0.1])\r\n by servername.hostname.com with esmtp id 1NGTS9-2C0sqG0; Fri, 4 Dec 2009\r\n 09:23:49 +0100",
+ r.generate(78)
+ );
}
- void testBugFix20110511()
- {
+ void testBugFix20110511() {
+
/*
Using the latest version of vmime (0.9.1), encoding the following string: Jean
@@ -520,8 +589,11 @@ VMIME_TEST_SUITE_BEGIN(textTest)
const std::string ENCODED_TEXT = "Jean =?utf-8?Q?Gwena=C3=ABl?= Dutourd";
// Encode
- VASSERT_EQ("encode", ENCODED_TEXT,
- vmime::text::newFromString(DECODED_TEXT, vmime::charset("utf-8"))->generate());
+ VASSERT_EQ(
+ "encode",
+ ENCODED_TEXT,
+ vmime::text::newFromString(DECODED_TEXT, vmime::charset("utf-8"))->generate()
+ );
// Decode
vmime::text t;
@@ -529,56 +601,69 @@ VMIME_TEST_SUITE_BEGIN(textTest)
// -- words
std::ostringstream oss; oss << t;
- VASSERT_EQ("decode1",
+ VASSERT_EQ(
+ "decode1",
"[text: [[word: charset=us-ascii, buffer=Jean ],"
"[word: charset=utf-8, buffer=Gwenaël],"
- "[word: charset=us-ascii, buffer= Dutourd]]]", oss.str());
+ "[word: charset=us-ascii, buffer= Dutourd]]]",
+ oss.str()
+ );
// -- getWholeBuffer
VASSERT_EQ("decode2", DECODED_TEXT, t.getWholeBuffer());
}
- void testInternationalizedEmail_specialChars()
- {
+ void testInternationalizedEmail_specialChars() {
+
vmime::generationContext ctx(vmime::generationContext::getDefaultContext());
ctx.setInternationalizedEmailSupport(true);
vmime::generationContext::switcher <vmime::generationContext> contextSwitcher(ctx);
// Special sequence/chars should still be encoded
- VASSERT_EQ("1", "=?us-ascii?Q?Test=3D=3Frfc2047_sequence?=",
- vmime::word("Test=?rfc2047 sequence", vmime::charset("us-ascii")).generate());
+ VASSERT_EQ(
+ "1",
+ "=?us-ascii?Q?Test=3D=3Frfc2047_sequence?=",
+ vmime::word("Test=?rfc2047 sequence", vmime::charset("us-ascii")).generate()
+ );
- VASSERT_EQ("2", "=?us-ascii?Q?Line_One=0ALine_Two?=",
- vmime::word("Line One\nLine Two", vmime::charset("us-ascii")).generate());
+ VASSERT_EQ(
+ "2",
+ "=?us-ascii?Q?Line_One=0ALine_Two?=",
+ vmime::word("Line One\nLine Two", vmime::charset("us-ascii")).generate()
+ );
}
- void testInternationalizedEmail_UTF8()
- {
+ void testInternationalizedEmail_UTF8() {
+
vmime::generationContext ctx(vmime::generationContext::getDefaultContext());
ctx.setInternationalizedEmailSupport(true);
vmime::generationContext::switcher <vmime::generationContext> contextSwitcher(ctx);
// Already UTF-8 encoded text should be left as is
- VASSERT_EQ("1", "Achim Br\xc3\xa4ndt",
- vmime::word("Achim Br\xc3\xa4ndt", vmime::charset("utf-8")).generate());
+ VASSERT_EQ(
+ "1", "Achim Br\xc3\xa4ndt",
+ vmime::word("Achim Br\xc3\xa4ndt", vmime::charset("utf-8")).generate()
+ );
}
- void testInternationalizedEmail_nonUTF8()
- {
+ void testInternationalizedEmail_nonUTF8() {
+
vmime::generationContext ctx(vmime::generationContext::getDefaultContext());
ctx.setInternationalizedEmailSupport(true);
vmime::generationContext::switcher <vmime::generationContext> contextSwitcher(ctx);
// Non UTF-8 encoded text should first be converted to UTF-8
- VASSERT_EQ("1", "Achim Br\xc3\xa4ndt",
- vmime::word("Achim Br\xe4ndt", vmime::charset("iso-8859-1")).generate());
+ VASSERT_EQ(
+ "1", "Achim Br\xc3\xa4ndt",
+ vmime::word("Achim Br\xe4ndt", vmime::charset("iso-8859-1")).generate()
+ );
}
- void testInternationalizedEmail_folding()
- {
+ void testInternationalizedEmail_folding() {
+
vmime::generationContext ctx(vmime::generationContext::getDefaultContext());
ctx.setInternationalizedEmailSupport(true);
@@ -588,63 +673,82 @@ VMIME_TEST_SUITE_BEGIN(textTest)
vmime::word w1("01234567890123456789\xc3\xa0x012345678901234567890123456789"
"01234567890123456789\xc3\xa0x012345678901234567890123456789", vmime::charset("utf-8"));
- VASSERT_EQ("1",
+ VASSERT_EQ(
+ "1",
"=?utf-8?Q?01234567890123456789=C3=A0x01234567890?=\r\n"
" =?utf-8?Q?1234567890123456789012345678901234567?=\r\n"
" =?utf-8?Q?89=C3=A0x0123456789012345678901234567?=\r\n"
- " =?utf-8?Q?89?=", w1.generate(50));
+ " =?utf-8?Q?89?=",
+ w1.generate(50)
+ );
// RFC-2047 encoding will not be forced, as words can be wrapped in a new line
vmime::word w2("bla bla bla This is some '\xc3\xa0\xc3\xa7' UTF-8 encoded text", vmime::charset("utf-8"));
- VASSERT_EQ("2",
+ VASSERT_EQ(
+ "2",
"bla bla bla This is\r\n"
" some '\xc3\xa0\xc3\xa7' UTF-8\r\n"
- " encoded text", w2.generate(20));
+ " encoded text",
+ w2.generate(20)
+ );
}
- void testWronglyPaddedB64Words()
- {
+ void testWronglyPaddedB64Words() {
+
vmime::text outText;
vmime::text::decodeAndUnfold("=?utf-8?B?5Lit5?=\n =?utf-8?B?paH?=", &outText);
- VASSERT_EQ("1", "\xe4\xb8\xad\xe6\x96\x87",
- outText.getConvertedText(vmime::charset("utf-8")));
+ VASSERT_EQ(
+ "1",
+ "\xe4\xb8\xad\xe6\x96\x87",
+ outText.getConvertedText(vmime::charset("utf-8"))
+ );
vmime::text::decodeAndUnfold("=?utf-8?B?5Lit5p?=\n =?utf-8?B?aH?=", &outText);
- VASSERT_EQ("2", "\xe4\xb8\xad\xe6\x96\x87",
- outText.getConvertedText(vmime::charset("utf-8")));
+ VASSERT_EQ(
+ "2",
+ "\xe4\xb8\xad\xe6\x96\x87",
+ outText.getConvertedText(vmime::charset("utf-8"))
+ );
vmime::text::decodeAndUnfold("=?utf-8?B?5Lit5pa?=\n =?utf-8?B?H?=", &outText);
- VASSERT_EQ("3", "\xe4\xb8\xad\xe6\x96\x87",
- outText.getConvertedText(vmime::charset("utf-8")));
+ VASSERT_EQ(
+ "3",
+ "\xe4\xb8\xad\xe6\x96\x87",
+ outText.getConvertedText(vmime::charset("utf-8"))
+ );
}
// Ensure that words which encode a non-integral number of characters
// are correctly decoded.
- void testFixBrokenWords()
- {
+ void testFixBrokenWords() {
+
vmime::text outText;
vmime::charsetConverterOptions opts;
opts.silentlyReplaceInvalidSequences = false; // just to be sure that broken words are actually fixed
// Test case 1
- vmime::text::decodeAndUnfold
- ("=?utf-8?Q?Gwena=C3?="
- "=?utf-8?Q?=ABl?=", &outText);
+ vmime::text::decodeAndUnfold(
+ "=?utf-8?Q?Gwena=C3?="
+ "=?utf-8?Q?=ABl?=",
+ &outText
+ );
VASSERT_EQ("1.1", 1, outText.getWordCount());
VASSERT_EQ("1.2", "Gwena\xc3\xabl", outText.getWordAt(0)->getBuffer());
VASSERT_EQ("1.3", vmime::charset("utf-8"), outText.getWordAt(0)->getCharset());
// Test case 2
- vmime::text::decodeAndUnfold
- ("=?utf-8?B?5Lit6Yu85qmf5qKw6JGj5LqL5pyDMTAz5bm056ysMDXlsYbn?="
- "=?utf-8?B?rKwwN+asoeitsOeoiw==?=", &outText);
+ vmime::text::decodeAndUnfold(
+ "=?utf-8?B?5Lit6Yu85qmf5qKw6JGj5LqL5pyDMTAz5bm056ysMDXlsYbn?="
+ "=?utf-8?B?rKwwN+asoeitsOeoiw==?=",
+ &outText
+ );
VASSERT_EQ("2.1", 1, outText.getWordCount());
VASSERT_EQ("2.2", "\xe4\xb8\xad\xe9\x8b\xbc\xe6\xa9\x9f\xe6\xa2\xb0"
@@ -654,21 +758,25 @@ VMIME_TEST_SUITE_BEGIN(textTest)
VASSERT_EQ("2.3", vmime::charset("utf-8"), outText.getWordAt(0)->getCharset());
// Test case 3 (a character spanning over 3 words: 'を' = E3 82 92)
- vmime::text::decodeAndUnfold
- ("=?utf-8?Q?abc=E3?="
- "=?utf-8?Q?=82?="
- "=?utf-8?Q?=92xyz?=", &outText);
+ vmime::text::decodeAndUnfold(
+ "=?utf-8?Q?abc=E3?="
+ "=?utf-8?Q?=82?="
+ "=?utf-8?Q?=92xyz?=",
+ &outText
+ );
VASSERT_EQ("3.1", 1, outText.getWordCount());
VASSERT_EQ("3.2", "abc\xe3\x82\x92xyz", outText.getWordAt(0)->getBuffer());
VASSERT_EQ("3.3", vmime::charset("utf-8"), outText.getWordAt(0)->getCharset());
// Test case 4 (remains invalid)
- vmime::text::decodeAndUnfold
- ("=?utf-8?Q?abc=E3?="
- "=?utf-8?Q?=82?="
- "=?utf-8?Q?xy?="
- "=?utf-8?Q?z?=", &outText);
+ vmime::text::decodeAndUnfold(
+ "=?utf-8?Q?abc=E3?="
+ "=?utf-8?Q?=82?="
+ "=?utf-8?Q?xy?="
+ "=?utf-8?Q?z?=",
+ &outText
+ );
VASSERT_EQ("4.1", 2, outText.getWordCount());
VASSERT_EQ("4.2", "abc", outText.getWordAt(0)->getBuffer());
@@ -677,11 +785,13 @@ VMIME_TEST_SUITE_BEGIN(textTest)
VASSERT_EQ("4.5", vmime::charset("utf-8"), outText.getWordAt(1)->getCharset());
// Test case 5 (remains partially invalid)
- vmime::text::decodeAndUnfold
- ("=?utf-8?Q?abc=E3?="
- "=?utf-8?Q?=82?="
- "=?utf-8?Q?\x92xy?="
- "=?utf-8?Q?z\xc3?=", &outText);
+ vmime::text::decodeAndUnfold(
+ "=?utf-8?Q?abc=E3?="
+ "=?utf-8?Q?=82?="
+ "=?utf-8?Q?\x92xy?="
+ "=?utf-8?Q?z\xc3?=",
+ &outText
+ );
VASSERT_EQ("5.1", 2, outText.getWordCount());
VASSERT_EQ("5.2", "abc\xe3\x82\x92xyz", outText.getWordAt(0)->getBuffer());
@@ -690,8 +800,8 @@ VMIME_TEST_SUITE_BEGIN(textTest)
VASSERT_EQ("5.5", vmime::charset("utf-8"), outText.getWordAt(1)->getCharset());
}
- void testUnknownCharset()
- {
+ void testUnknownCharset() {
+
vmime::text t;
vmime::text::decodeAndUnfold("=?gb2312?B?wdaRY8PA?=", &t);
@@ -721,4 +831,3 @@ VMIME_TEST_SUITE_BEGIN(textTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/parser/wordEncoderTest.cpp b/tests/parser/wordEncoderTest.cpp
index c3c44a87..08d34aa4 100644
--- a/tests/parser/wordEncoderTest.cpp
+++ b/tests/parser/wordEncoderTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -40,88 +40,133 @@ VMIME_TEST_SUITE_BEGIN(wordEncoderTest)
VMIME_TEST_LIST_END
- void testGetNextChunk()
- {
+ void testGetNextChunk() {
+
// An integral number of characters should be encoded
vmime::wordEncoder we(
"bufferfoobarbaz",
vmime::charset("utf-8"),
- vmime::wordEncoder::ENCODING_AUTO);
+ vmime::wordEncoder::ENCODING_AUTO
+ );
VASSERT_EQ("1", "buffer", we.getNextChunk(6));
VASSERT_EQ("2", "foo", we.getNextChunk(3));
VASSERT_EQ("3", "barbaz", we.getNextChunk(10));
}
- void testGetNextChunk_integral()
- {
+ void testGetNextChunk_integral() {
+
// An integral number of characters should be encoded
vmime::wordEncoder we(
"buffer\xc3\xa0plop",
vmime::charset("utf-8"),
- vmime::wordEncoder::ENCODING_AUTO);
+ vmime::wordEncoder::ENCODING_AUTO
+ );
VASSERT_EQ("1", "buffer=C3=A0", we.getNextChunk(7));
VASSERT_EQ("2", "plop", we.getNextChunk(10));
}
- void testIsEncodingNeeded_ascii()
- {
+ void testIsEncodingNeeded_ascii() {
+
vmime::generationContext ctx(vmime::generationContext::getDefaultContext());
ctx.setInternationalizedEmailSupport(false);
- VASSERT_FALSE("ascii", vmime::wordEncoder::isEncodingNeeded
- (ctx, "ASCII-only buffer", vmime::charset("utf-8"), ""));
+ VASSERT_FALSE(
+ "ascii",
+ vmime::wordEncoder::isEncodingNeeded(
+ ctx, "ASCII-only buffer", vmime::charset("utf-8"), ""
+ )
+ );
- VASSERT_TRUE("non-ascii", vmime::wordEncoder::isEncodingNeeded
- (ctx, "Buffer with some UTF-8 '\xc3\xa0'", vmime::charset("utf-8"), ""));
+ VASSERT_TRUE(
+ "non-ascii",
+ vmime::wordEncoder::isEncodingNeeded(
+ ctx, "Buffer with some UTF-8 '\xc3\xa0'", vmime::charset("utf-8"), ""
+ )
+ );
}
- void testIsEncodingNeeded_withLanguage()
- {
- VASSERT_TRUE("ascii", vmime::wordEncoder::isEncodingNeeded
- (vmime::generationContext::getDefaultContext(), "ASCII-only buffer", vmime::charset("utf-8"), "en"));
+ void testIsEncodingNeeded_withLanguage() {
+
+ VASSERT_TRUE(
+ "ascii",
+ vmime::wordEncoder::isEncodingNeeded(
+ vmime::generationContext::getDefaultContext(),
+ "ASCII-only buffer",
+ vmime::charset("utf-8"),
+ "en"
+ )
+ );
}
- void testIsEncodingNeeded_specialChars()
- {
- VASSERT_TRUE("rfc2047", vmime::wordEncoder::isEncodingNeeded
- (vmime::generationContext::getDefaultContext(),
- "foo bar =? foo bar", vmime::charset("us-ascii"), ""));
+ void testIsEncodingNeeded_specialChars() {
- VASSERT_TRUE("new line 1", vmime::wordEncoder::isEncodingNeeded
- (vmime::generationContext::getDefaultContext(),
- "foo bar \n foo bar", vmime::charset("us-ascii"), ""));
+ VASSERT_TRUE(
+ "rfc2047",
+ vmime::wordEncoder::isEncodingNeeded(
+ vmime::generationContext::getDefaultContext(),
+ "foo bar =? foo bar",
+ vmime::charset("us-ascii"),
+ ""
+ )
+ );
- VASSERT_TRUE("new line 2", vmime::wordEncoder::isEncodingNeeded
- (vmime::generationContext::getDefaultContext(),
- "foo bar \r foo bar", vmime::charset("us-ascii"), ""));
+ VASSERT_TRUE(
+ "new line 1",
+ vmime::wordEncoder::isEncodingNeeded(
+ vmime::generationContext::getDefaultContext(),
+ "foo bar \n foo bar",
+ vmime::charset("us-ascii"),
+ ""
+ )
+ );
+
+ VASSERT_TRUE(
+ "new line 2",
+ vmime::wordEncoder::isEncodingNeeded(
+ vmime::generationContext::getDefaultContext(),
+ "foo bar \r foo bar",
+ vmime::charset("us-ascii"),
+ ""
+ )
+ );
}
- void testGuessBestEncoding_QP()
- {
- VASSERT_EQ("1", vmime::wordEncoder::ENCODING_QP,
- vmime::wordEncoder::guessBestEncoding("ASCII only buffer", vmime::charset("us-ascii")));
+ void testGuessBestEncoding_QP() {
+
+ VASSERT_EQ(
+ "1",
+ vmime::wordEncoder::ENCODING_QP,
+ vmime::wordEncoder::guessBestEncoding("ASCII only buffer", vmime::charset("us-ascii"))
+ );
}
- void testGuessBestEncoding_B64()
- {
+ void testGuessBestEncoding_B64() {
+
// >= 40% non-ASCII => Base64...
- VASSERT_EQ("1", vmime::wordEncoder::ENCODING_B64,
- vmime::wordEncoder::guessBestEncoding("xxxxx\xc3\xa0\xc3\xa0", vmime::charset("utf-8")));
+ VASSERT_EQ(
+ "1",
+ vmime::wordEncoder::ENCODING_B64,
+ vmime::wordEncoder::guessBestEncoding("xxxxx\xc3\xa0\xc3\xa0", vmime::charset("utf-8"))
+ );
// ...else Quoted-Printable
- VASSERT_EQ("2", vmime::wordEncoder::ENCODING_QP,
- vmime::wordEncoder::guessBestEncoding("xxxxxx\xc3\xa0\xc3\xa0", vmime::charset("utf-8")));
+ VASSERT_EQ(
+ "2",
+ vmime::wordEncoder::ENCODING_QP,
+ vmime::wordEncoder::guessBestEncoding("xxxxxx\xc3\xa0\xc3\xa0", vmime::charset("utf-8"))
+ );
}
- void testEncodeQP_RFC2047()
- {
+ void testEncodeQP_RFC2047() {
+
// When Quoted-Printable is used, it should be RFC-2047 QP encoding
vmime::wordEncoder we(
"buffer\xc3\xa0 foo_bar",
vmime::charset("utf-8"),
- vmime::wordEncoder::ENCODING_AUTO);
+ vmime::wordEncoder::ENCODING_AUTO
+ );
VASSERT_EQ("1", "buffer=C3=A0_foo=5Fbar", we.getNextChunk(100));
}