aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/misc/importanceHelperTest.cpp129
-rw-r--r--tests/net/folderAttributesTest.cpp34
-rw-r--r--tests/net/imap/IMAPCommandTest.cpp152
-rw-r--r--tests/net/imap/IMAPParserTest.cpp30
-rw-r--r--tests/net/imap/IMAPTagTest.cpp24
-rw-r--r--tests/net/imap/IMAPUtilsTest.cpp38
-rw-r--r--tests/net/maildir/maildirStoreTest.cpp223
-rw-r--r--tests/net/maildir/maildirUtilsTest.cpp13
-rw-r--r--tests/net/messageSetTest.cpp102
-rw-r--r--tests/net/pop3/POP3CommandTest.cpp95
-rw-r--r--tests/net/pop3/POP3ResponseTest.cpp80
-rw-r--r--tests/net/pop3/POP3StoreTest.cpp10
-rw-r--r--tests/net/pop3/POP3TestUtils.hpp33
-rw-r--r--tests/net/pop3/POP3UtilsTest.cpp23
-rw-r--r--tests/net/smtp/SMTPCommandSetTest.cpp34
-rw-r--r--tests/net/smtp/SMTPCommandTest.cpp119
-rw-r--r--tests/net/smtp/SMTPResponseTest.cpp84
-rw-r--r--tests/net/smtp/SMTPTransportTest.cpp112
-rw-r--r--tests/net/smtp/SMTPTransportTestUtils.hpp509
-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.cpp129
-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.cpp427
-rw-r--r--tests/parser/wordEncoderTest.cpp131
-rw-r--r--tests/security/digest/md5Test.cpp63
-rw-r--r--tests/security/digest/sha1Test.cpp26
-rw-r--r--tests/testRunner.cpp139
-rw-r--r--tests/testUtils.cpp201
-rw-r--r--tests/testUtils.hpp147
-rw-r--r--tests/utility/datetimeUtilsTest.cpp43
-rw-r--r--tests/utility/encoder/b64EncoderTest.cpp55
-rw-r--r--tests/utility/encoder/encoderFactoryTest.cpp10
-rw-r--r--tests/utility/encoder/encoderTestUtils.hpp31
-rw-r--r--tests/utility/encoder/qpEncoderTest.cpp115
-rw-r--r--tests/utility/filteredStreamTest.cpp105
-rw-r--r--tests/utility/outputStreamByteArrayAdapterTest.cpp15
-rw-r--r--tests/utility/outputStreamSocketAdapterTest.cpp15
-rw-r--r--tests/utility/outputStreamStringAdapterTest.cpp15
-rw-r--r--tests/utility/parserInputStreamAdapterTest.cpp6
-rw-r--r--tests/utility/pathTest.cpp79
-rw-r--r--tests/utility/seekableInputStreamRegionAdapterTest.cpp57
-rw-r--r--tests/utility/stringProxyTest.cpp31
-rw-r--r--tests/utility/stringUtilsTest.cpp75
-rw-r--r--tests/utility/urlTest.cpp100
66 files changed, 2816 insertions, 2288 deletions
diff --git a/tests/misc/importanceHelperTest.cpp b/tests/misc/importanceHelperTest.cpp
index 53c5c679..d04d730b 100644
--- a/tests/misc/importanceHelperTest.cpp
+++ b/tests/misc/importanceHelperTest.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
@@ -47,8 +47,8 @@ VMIME_TEST_SUITE_BEGIN(importanceHelperTest)
// resetImportance
- void testResetImportance()
- {
+ void testResetImportance() {
+
vmime::shared_ptr <vmime::header> hdr = vmime::make_shared <vmime::header>();
hdr->getField("Importance")->setValue("xxx");
@@ -66,9 +66,12 @@ VMIME_TEST_SUITE_BEGIN(importanceHelperTest)
// setImportance
- void testSetImportanceImpl(const vmime::misc::importanceHelper::Importance i,
- const std::string& ImportanceValue, const std::string& XPriorityValue)
- {
+ void testSetImportanceImpl(
+ const vmime::misc::importanceHelper::Importance i,
+ const std::string& ImportanceValue,
+ const std::string& XPriorityValue
+ ) {
+
vmime::shared_ptr <vmime::header> hdr = vmime::make_shared <vmime::header>();
vmime::misc::importanceHelper::setImportanceHeader(hdr, i);
@@ -80,43 +83,56 @@ VMIME_TEST_SUITE_BEGIN(importanceHelperTest)
VASSERT_EQ("4", XPriorityValue, hdr->findField("X-Priority")->getValue()->generate());
}
- void testSetImportance1()
- {
- testSetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_HIGHEST,
- "high", "1 (Highest)");
+ void testSetImportance1() {
+
+ testSetImportanceImpl(
+ vmime::misc::importanceHelper::IMPORTANCE_HIGHEST,
+ "high", "1 (Highest)"
+ );
}
- void testSetImportance2()
- {
- testSetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_HIGH,
- "high", "2 (High)");
+ void testSetImportance2() {
+
+ testSetImportanceImpl(
+ vmime::misc::importanceHelper::IMPORTANCE_HIGH,
+ "high", "2 (High)"
+ );
}
- void testSetImportance3()
- {
- testSetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_NORMAL,
- "normal", "3 (Normal)");
+ void testSetImportance3() {
+
+ testSetImportanceImpl(
+ vmime::misc::importanceHelper::IMPORTANCE_NORMAL,
+ "normal", "3 (Normal)"
+ );
}
- void testSetImportance4()
- {
- testSetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_LOW,
- "low", "4 (Low)");
+ void testSetImportance4() {
+
+ testSetImportanceImpl(
+ vmime::misc::importanceHelper::IMPORTANCE_LOW,
+ "low", "4 (Low)"
+ );
}
- void testSetImportance5()
- {
- testSetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_LOWEST,
- "low", "5 (Lowest)");
+ void testSetImportance5() {
+
+ testSetImportanceImpl(
+ vmime::misc::importanceHelper::IMPORTANCE_LOWEST,
+ "low", "5 (Lowest)"
+ );
}
// getImportance
- void testGetImportanceImpl(const vmime::misc::importanceHelper::Importance i1,
+ void testGetImportanceImpl(
+ const vmime::misc::importanceHelper::Importance i1,
const vmime::misc::importanceHelper::Importance i2,
- const std::string& ImportanceValue, const std::string& XPriorityValue)
- {
+ const std::string& ImportanceValue,
+ const std::string& XPriorityValue
+ ) {
+
vmime::shared_ptr <vmime::header> hdr1 = vmime::make_shared <vmime::header>();
hdr1->getField("Importance")->setValue(ImportanceValue);
@@ -128,35 +144,48 @@ VMIME_TEST_SUITE_BEGIN(importanceHelperTest)
VASSERT_EQ("2", i2, vmime::misc::importanceHelper::getImportanceHeader(hdr2));
}
- void testGetImportance1()
- {
- testGetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_HIGHEST,
- vmime::misc::importanceHelper::IMPORTANCE_HIGHEST, "high", "1 (Highest)");
+ void testGetImportance1() {
+
+ testGetImportanceImpl(
+ vmime::misc::importanceHelper::IMPORTANCE_HIGHEST,
+ vmime::misc::importanceHelper::IMPORTANCE_HIGHEST,
+ "high", "1 (Highest)");
}
- void testGetImportance2()
- {
- testGetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_HIGHEST,
- vmime::misc::importanceHelper::IMPORTANCE_HIGH, "high", "2 (High)");
+ void testGetImportance2() {
+
+ testGetImportanceImpl(
+ vmime::misc::importanceHelper::IMPORTANCE_HIGHEST,
+ vmime::misc::importanceHelper::IMPORTANCE_HIGH,
+ "high", "2 (High)"
+ );
}
- void testGetImportance3()
- {
- testGetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_NORMAL,
- vmime::misc::importanceHelper::IMPORTANCE_NORMAL, "normal", "3 (Normal)");
+ void testGetImportance3() {
+
+ testGetImportanceImpl(
+ vmime::misc::importanceHelper::IMPORTANCE_NORMAL,
+ vmime::misc::importanceHelper::IMPORTANCE_NORMAL,
+ "normal", "3 (Normal)"
+ );
}
- void testGetImportance4()
- {
- testGetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_LOWEST,
- vmime::misc::importanceHelper::IMPORTANCE_LOW, "low", "4 (Low)");
+ void testGetImportance4() {
+
+ testGetImportanceImpl(
+ vmime::misc::importanceHelper::IMPORTANCE_LOWEST,
+ vmime::misc::importanceHelper::IMPORTANCE_LOW,
+ "low", "4 (Low)"
+ );
}
- void testGetImportance5()
- {
- testGetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_LOWEST,
- vmime::misc::importanceHelper::IMPORTANCE_LOWEST, "low", "5 (Lowest)");
+ void testGetImportance5() {
+
+ testGetImportanceImpl(
+ vmime::misc::importanceHelper::IMPORTANCE_LOWEST,
+ vmime::misc::importanceHelper::IMPORTANCE_LOWEST,
+ "low", "5 (Lowest)"
+ );
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/net/folderAttributesTest.cpp b/tests/net/folderAttributesTest.cpp
index 06235399..da0e025d 100644
--- a/tests/net/folderAttributesTest.cpp
+++ b/tests/net/folderAttributesTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2014 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(folderAttributesTest)
VMIME_TEST_LIST_END
- void testConstruct()
- {
+ void testConstruct() {
+
vmime::net::folderAttributes attr;
// Default values
@@ -52,8 +52,8 @@ VMIME_TEST_SUITE_BEGIN(folderAttributesTest)
VASSERT_EQ("special-use", vmime::net::folderAttributes::SPECIALUSE_NONE, attr.getSpecialUse());
}
- void testConstructCopy()
- {
+ void testConstructCopy() {
+
std::vector <vmime::string> userFlags;
userFlags.push_back("\\XMyFlag1");
userFlags.push_back("\\XMyFlag2");
@@ -70,24 +70,24 @@ VMIME_TEST_SUITE_BEGIN(folderAttributesTest)
VASSERT("user-flags", attr2.getUserFlags() == attr.getUserFlags());
}
- void testSetType()
- {
+ void testSetType() {
+
vmime::net::folderAttributes attr;
attr.setType(vmime::net::folderAttributes::TYPE_CONTAINS_FOLDERS);
VASSERT_EQ("eq", vmime::net::folderAttributes::TYPE_CONTAINS_FOLDERS, attr.getType());
}
- void testSetFlags()
- {
+ void testSetFlags() {
+
vmime::net::folderAttributes attr;
attr.setFlags(vmime::net::folderAttributes::FLAG_HAS_CHILDREN);
VASSERT_EQ("eq", vmime::net::folderAttributes::FLAG_HAS_CHILDREN, attr.getFlags());
}
- void testHasFlag()
- {
+ void testHasFlag() {
+
vmime::net::folderAttributes attr;
attr.setFlags(vmime::net::folderAttributes::FLAG_HAS_CHILDREN);
@@ -95,8 +95,8 @@ VMIME_TEST_SUITE_BEGIN(folderAttributesTest)
VASSERT("has-not", !attr.hasFlag(vmime::net::folderAttributes::FLAG_NO_OPEN));
}
- void testSetUserFlags()
- {
+ void testSetUserFlags() {
+
std::vector <vmime::string> userFlags;
userFlags.push_back("\\XMyFlag1");
userFlags.push_back("\\XMyFlag2");
@@ -108,8 +108,8 @@ VMIME_TEST_SUITE_BEGIN(folderAttributesTest)
VASSERT("eq", attr.getUserFlags() == userFlags);
}
- void testHasUserFlag()
- {
+ void testHasUserFlag() {
+
std::vector <vmime::string> userFlags;
userFlags.push_back("\\XMyFlag1");
userFlags.push_back("\\XMyFlag2");
@@ -123,8 +123,8 @@ VMIME_TEST_SUITE_BEGIN(folderAttributesTest)
VASSERT("has-not", !attr.hasUserFlag("\\XMyFlag4"));
}
- void testSetSpecialUse()
- {
+ void testSetSpecialUse() {
+
const int use = vmime::net::folderAttributes::SPECIALUSE_JUNK
| vmime::net::folderAttributes::SPECIALUSE_TRASH;
diff --git a/tests/net/imap/IMAPCommandTest.cpp b/tests/net/imap/IMAPCommandTest.cpp
index f274bb27..cf3446d7 100644
--- a/tests/net/imap/IMAPCommandTest.cpp
+++ b/tests/net/imap/IMAPCommandTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2014 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
@@ -60,24 +60,24 @@ VMIME_TEST_SUITE_BEGIN(IMAPCommandTest)
VMIME_TEST_LIST_END
- void testCreateCommand()
- {
+ void testCreateCommand() {
+
vmime::shared_ptr <IMAPCommand> cmd = IMAPCommand::createCommand("MY_COMMAND");
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "MY_COMMAND", cmd->getText());
}
- void testCreateCommandParams()
- {
+ void testCreateCommandParams() {
+
vmime::shared_ptr <IMAPCommand> cmd = IMAPCommand::createCommand("MY_COMMAND param1 param2");
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "MY_COMMAND param1 param2", cmd->getText());
}
- void testLOGIN()
- {
+ void testLOGIN() {
+
vmime::shared_ptr <IMAPCommand> cmd = IMAPCommand::LOGIN("username", "password");
VASSERT_NOT_NULL("Not null", cmd);
@@ -85,24 +85,24 @@ VMIME_TEST_SUITE_BEGIN(IMAPCommandTest)
VASSERT_EQ("Trace Text", "LOGIN {username} {password}", cmd->getTraceText());
}
- void testAUTHENTICATE()
- {
+ void testAUTHENTICATE() {
+
vmime::shared_ptr <IMAPCommand> cmd = IMAPCommand::AUTHENTICATE("saslmechanism");
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "AUTHENTICATE saslmechanism", cmd->getText());
}
- void testAUTHENTICATE_InitialResponse()
- {
+ void testAUTHENTICATE_InitialResponse() {
+
vmime::shared_ptr <IMAPCommand> cmd = IMAPCommand::AUTHENTICATE("saslmechanism", "initial-response");
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "AUTHENTICATE saslmechanism initial-response", cmd->getText());
}
- void testLIST()
- {
+ void testLIST() {
+
vmime::shared_ptr <IMAPCommand> cmd = IMAPCommand::LIST("ref-name", "mailbox-name");
VASSERT_NOT_NULL("Not null", cmd);
@@ -114,47 +114,52 @@ VMIME_TEST_SUITE_BEGIN(IMAPCommandTest)
VASSERT_EQ("Text", "LIST \"ref name\" mailbox-name", cmdQuote->getText());
}
- void testSELECT()
- {
+ void testSELECT() {
+
std::vector <vmime::string> params;
params.push_back("param-1");
params.push_back("param-2");
- vmime::shared_ptr <IMAPCommand> cmdRO = IMAPCommand::SELECT
- (/* readOnly */ true, "mailbox-name", std::vector <vmime::string>());
+ vmime::shared_ptr <IMAPCommand> cmdRO = IMAPCommand::SELECT(
+ /* readOnly */ true, "mailbox-name", std::vector <vmime::string>()
+ );
VASSERT_NOT_NULL("Not null", cmdRO);
VASSERT_EQ("Text", "EXAMINE mailbox-name", cmdRO->getText());
- vmime::shared_ptr <IMAPCommand> cmdROQuote = IMAPCommand::SELECT
- (/* readOnly */ true, "mailbox name", std::vector <vmime::string>());
+ vmime::shared_ptr <IMAPCommand> cmdROQuote = IMAPCommand::SELECT(
+ /* readOnly */ true, "mailbox name", std::vector <vmime::string>()
+ );
VASSERT_NOT_NULL("Not null", cmdROQuote);
VASSERT_EQ("Text", "EXAMINE \"mailbox name\"", cmdROQuote->getText());
- vmime::shared_ptr <IMAPCommand> cmdRW = IMAPCommand::SELECT
- (/* readOnly */ false, "mailbox-name", std::vector <vmime::string>());
+ vmime::shared_ptr <IMAPCommand> cmdRW = IMAPCommand::SELECT(
+ /* readOnly */ false, "mailbox-name", std::vector <vmime::string>()
+ );
VASSERT_NOT_NULL("Not null", cmdRW);
VASSERT_EQ("Text", "SELECT mailbox-name", cmdRW->getText());
- vmime::shared_ptr <IMAPCommand> cmdRWParams = IMAPCommand::SELECT
- (/* readOnly */ false, "mailbox-name", params);
+ vmime::shared_ptr <IMAPCommand> cmdRWParams = IMAPCommand::SELECT(
+ /* readOnly */ false, "mailbox-name", params
+ );
VASSERT_NOT_NULL("Not null", cmdRWParams);
VASSERT_EQ("Text", "SELECT mailbox-name (param-1 param-2)", cmdRWParams->getText());
- vmime::shared_ptr <IMAPCommand> cmdRWQuote = IMAPCommand::SELECT
- (/* readOnly */ false, "mailbox name", std::vector <vmime::string>());
+ vmime::shared_ptr <IMAPCommand> cmdRWQuote = IMAPCommand::SELECT(
+ /* readOnly */ false, "mailbox name", std::vector <vmime::string>()
+ );
VASSERT_NOT_NULL("Not null", cmdRWQuote);
VASSERT_EQ("Text", "SELECT \"mailbox name\"", cmdRWQuote->getText());
}
- void testSTATUS()
- {
+ void testSTATUS() {
+
std::vector <vmime::string> attribs;
attribs.push_back("attrib-1");
attribs.push_back("attrib-2");
@@ -174,8 +179,8 @@ VMIME_TEST_SUITE_BEGIN(IMAPCommandTest)
VASSERT_EQ("Text", "STATUS \"mailbox name\" (attrib-1 attrib-2)", cmdQuote->getText());
}
- void testCREATE()
- {
+ void testCREATE() {
+
std::vector <vmime::string> params;
params.push_back("param-1");
params.push_back("param-2");
@@ -202,8 +207,8 @@ VMIME_TEST_SUITE_BEGIN(IMAPCommandTest)
VASSERT_EQ("Text", "CREATE mailbox-name", cmdNoParam->getText());
}
- void testDELETE()
- {
+ void testDELETE() {
+
vmime::shared_ptr <IMAPCommand> cmd =
IMAPCommand::DELETE("mailbox-name");
@@ -218,8 +223,8 @@ VMIME_TEST_SUITE_BEGIN(IMAPCommandTest)
VASSERT_EQ("Text", "DELETE \"mailbox name\"", cmdQuote->getText());
}
- void testRENAME()
- {
+ void testRENAME() {
+
vmime::shared_ptr <IMAPCommand> cmd =
IMAPCommand::RENAME("mailbox-name", "new-mailbox-name");
@@ -234,8 +239,8 @@ VMIME_TEST_SUITE_BEGIN(IMAPCommandTest)
VASSERT_EQ("Text", "RENAME \"mailbox name\" \"new mailbox name\"", cmdQuote->getText());
}
- void testFETCH()
- {
+ void testFETCH() {
+
std::vector <vmime::string> params;
params.push_back("param-1");
params.push_back("param-2");
@@ -269,57 +274,63 @@ VMIME_TEST_SUITE_BEGIN(IMAPCommandTest)
VASSERT_EQ("Text", "UID FETCH 42:47 (param-1 param-2)", cmdUIDs->getText());
}
- void testSTORE()
- {
+ void testSTORE() {
+
std::vector <vmime::string> flags;
flags.push_back("flag-1");
flags.push_back("flag-2");
- vmime::shared_ptr <IMAPCommand> cmdNum = IMAPCommand::STORE
- (vmime::net::messageSet::byNumber(42), vmime::net::message::FLAG_MODE_SET, flags);
+ vmime::shared_ptr <IMAPCommand> cmdNum = IMAPCommand::STORE(
+ vmime::net::messageSet::byNumber(42), vmime::net::message::FLAG_MODE_SET, flags
+ );
VASSERT_NOT_NULL("Not null", cmdNum);
VASSERT_EQ("Text", "STORE 42 FLAGS (flag-1 flag-2)", cmdNum->getText());
- vmime::shared_ptr <IMAPCommand> cmdNums = IMAPCommand::STORE
- (vmime::net::messageSet::byNumber(42, 47), vmime::net::message::FLAG_MODE_SET, flags);
+ vmime::shared_ptr <IMAPCommand> cmdNums = IMAPCommand::STORE(
+ vmime::net::messageSet::byNumber(42, 47), vmime::net::message::FLAG_MODE_SET, flags
+ );
VASSERT_NOT_NULL("Not null", cmdNums);
VASSERT_EQ("Text", "STORE 42:47 FLAGS (flag-1 flag-2)", cmdNums->getText());
- vmime::shared_ptr <IMAPCommand> cmdUID = IMAPCommand::STORE
- (vmime::net::messageSet::byUID(42), vmime::net::message::FLAG_MODE_SET, flags);
+ vmime::shared_ptr <IMAPCommand> cmdUID = IMAPCommand::STORE(
+ vmime::net::messageSet::byUID(42), vmime::net::message::FLAG_MODE_SET, flags
+ );
VASSERT_NOT_NULL("Not null", cmdUID);
VASSERT_EQ("Text", "UID STORE 42 FLAGS (flag-1 flag-2)", cmdUID->getText());
- vmime::shared_ptr <IMAPCommand> cmdUIDs = IMAPCommand::STORE
- (vmime::net::messageSet::byUID(42, 47), vmime::net::message::FLAG_MODE_SET, flags);
+ vmime::shared_ptr <IMAPCommand> cmdUIDs = IMAPCommand::STORE(
+ vmime::net::messageSet::byUID(42, 47), vmime::net::message::FLAG_MODE_SET, flags
+ );
VASSERT_NOT_NULL("Not null", cmdUIDs);
VASSERT_EQ("Text", "UID STORE 42:47 FLAGS (flag-1 flag-2)", cmdUIDs->getText());
- vmime::shared_ptr <IMAPCommand> cmdAdd = IMAPCommand::STORE
- (vmime::net::messageSet::byUID(42, 47), vmime::net::message::FLAG_MODE_ADD, flags);
+ vmime::shared_ptr <IMAPCommand> cmdAdd = IMAPCommand::STORE(
+ vmime::net::messageSet::byUID(42, 47), vmime::net::message::FLAG_MODE_ADD, flags
+ );
VASSERT_NOT_NULL("Not null", cmdAdd);
VASSERT_EQ("Text", "UID STORE 42:47 +FLAGS (flag-1 flag-2)", cmdAdd->getText());
- vmime::shared_ptr <IMAPCommand> cmdRem = IMAPCommand::STORE
- (vmime::net::messageSet::byUID(42, 47), vmime::net::message::FLAG_MODE_REMOVE, flags);
+ vmime::shared_ptr <IMAPCommand> cmdRem = IMAPCommand::STORE(
+ vmime::net::messageSet::byUID(42, 47), vmime::net::message::FLAG_MODE_REMOVE, flags
+ );
VASSERT_NOT_NULL("Not null", cmdRem);
VASSERT_EQ("Text", "UID STORE 42:47 -FLAGS (flag-1 flag-2)", cmdRem->getText());
}
- void testAPPEND()
- {
+ void testAPPEND() {
+
std::vector <vmime::string> flags;
flags.push_back("flag-1");
flags.push_back("flag-2");
@@ -347,8 +358,8 @@ VMIME_TEST_SUITE_BEGIN(IMAPCommandTest)
VASSERT_EQ("Text", "APPEND \"mailbox name\" (flag-1 flag-2) \"15-Mar-2014 23:11:47 +0200\" {1234}", cmdDate->getText());
}
- void testCOPY()
- {
+ void testCOPY() {
+
vmime::shared_ptr <IMAPCommand> cmdNum =
IMAPCommand::COPY(vmime::net::messageSet::byNumber(42), "mailbox-name");
@@ -384,8 +395,8 @@ VMIME_TEST_SUITE_BEGIN(IMAPCommandTest)
VASSERT_EQ("Text", "COPY 42:47 \"mailbox name\"", cmdQuote->getText());
}
- void testSEARCH()
- {
+ void testSEARCH() {
+
std::vector <vmime::string> searchKeys;
searchKeys.push_back("search-key-1");
searchKeys.push_back("search-key-2");
@@ -406,57 +417,58 @@ VMIME_TEST_SUITE_BEGIN(IMAPCommandTest)
VASSERT_EQ("Text", "SEARCH CHARSET test-charset search-key-1 search-key-2", cmdCset->getText());
}
- void testSTARTTLS()
- {
+ void testSTARTTLS() {
+
vmime::shared_ptr <IMAPCommand> cmd = IMAPCommand::STARTTLS();
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "STARTTLS", cmd->getText());
}
- void testCAPABILITY()
- {
+ void testCAPABILITY() {
+
vmime::shared_ptr <IMAPCommand> cmd = IMAPCommand::CAPABILITY();
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "CAPABILITY", cmd->getText());
}
- void testNOOP()
- {
+ void testNOOP() {
+
vmime::shared_ptr <IMAPCommand> cmd = IMAPCommand::NOOP();
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "NOOP", cmd->getText());
}
- void testEXPUNGE()
- {
+ void testEXPUNGE() {
+
vmime::shared_ptr <IMAPCommand> cmd = IMAPCommand::EXPUNGE();
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "EXPUNGE", cmd->getText());
}
- void testCLOSE()
- {
+ void testCLOSE() {
+
vmime::shared_ptr <IMAPCommand> cmd = IMAPCommand::CLOSE();
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "CLOSE", cmd->getText());
}
- void testLOGOUT()
- {
+ void testLOGOUT() {
+
vmime::shared_ptr <IMAPCommand> cmd = IMAPCommand::LOGOUT();
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "LOGOUT", cmd->getText());
}
- void testSend()
- {
- vmime::shared_ptr <IMAPCommand> cmd = IMAPCommand::createCommand("MY_COMMAND param1 param2");
+ void testSend() {
+
+ vmime::shared_ptr <IMAPCommand> cmd =
+ IMAPCommand::createCommand("MY_COMMAND param1 param2");
vmime::shared_ptr <vmime::net::session> sess = vmime::net::session::create();
diff --git a/tests/net/imap/IMAPParserTest.cpp b/tests/net/imap/IMAPParserTest.cpp
index 5d810a8f..974dc241 100644
--- a/tests/net/imap/IMAPParserTest.cpp
+++ b/tests/net/imap/IMAPParserTest.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,8 +39,8 @@ VMIME_TEST_SUITE_BEGIN(IMAPParserTest)
// For Apple iCloud IMAP server
- void testExtraSpaceInCapaResponse()
- {
+ void testExtraSpaceInCapaResponse() {
+
vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>();
@@ -49,7 +49,8 @@ VMIME_TEST_SUITE_BEGIN(IMAPParserTest)
socket->localSend(
"* CAPABILITY IMAP4rev1 AUTH=ATOKEN AUTH=PLAIN \r\n" // extra space at end
- "a001 OK Capability completed.\r\n");
+ "a001 OK Capability completed.\r\n"
+ );
vmime::shared_ptr <vmime::net::imap::IMAPParser> parser =
vmime::make_shared <vmime::net::imap::IMAPParser>();
@@ -65,15 +66,16 @@ VMIME_TEST_SUITE_BEGIN(IMAPParserTest)
socket->localSend(
"* CAPABILITY IMAP4rev1 AUTH=ATOKEN AUTH=PLAIN \r\n" // extra space at end
- "a002 OK Capability completed.\r\n");
+ "a002 OK Capability completed.\r\n"
+ );
parser->setStrict(true);
VASSERT_THROW("strict mode", parser->readResponse(/* literalHandler */ NULL), vmime::exceptions::invalid_response);
}
// For Apple iCloud/Exchange IMAP server
- void testContinueReqWithoutSpace()
- {
+ void testContinueReqWithoutSpace() {
+
// continue_req ::= "+" SPACE (resp_text / base64)
//
// Some servers do not send SPACE when response text is empty.
@@ -114,8 +116,8 @@ VMIME_TEST_SUITE_BEGIN(IMAPParserTest)
// that is running the Exchange Server 2007 IMAP4 service, a corrupted
// response is sent as a reply
// --> http://support.microsoft.com/kb/975918/en-us
- void testNILValueInBodyFldEnc()
- {
+ void testNILValueInBodyFldEnc() {
+
vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>();
@@ -145,13 +147,13 @@ VMIME_TEST_SUITE_BEGIN(IMAPParserTest)
}
// "body_fld_lang" is optional after "body_fld_dsp" in "body_ext_mpart" (Yahoo)
- void testFETCHResponse_optional_body_fld_lang()
- {
+ void testFETCHResponse_optional_body_fld_lang() {
+
vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>();
vmime::shared_ptr <vmime::net::imap::IMAPTag> tag =
- vmime::make_shared <vmime::net::imap::IMAPTag>();
+ vmime::make_shared <vmime::net::imap::IMAPTag>();
const char* resp = "* 1 FETCH (UID 7 RFC822.SIZE 694142 BODYSTRUCTURE (((\"text\" \"plain\" (\"charset\" \"utf-8\") NIL NIL \"7bit\" 0 0 NIL NIL NIL NIL)(\"text\" \"html\" (\"charset\" \"utf-8\") NIL NIL \"7bit\" 193 0 NIL NIL NIL NIL) \"alternative\" (\"boundary\" \"----=_Part_536_109505883.1410847112666\") NIL)(\"image\" \"jpeg\" NIL \"<[email protected]>\" NIL \"base64\" 351784 NIL (\"attachment\" (\"name\" \"att2\" \"filename\" \"9.jpg\")) NIL NIL)(\"image\" \"jpeg\" NIL \"<[email protected]>\" NIL \"base64\" 337676 NIL (\"attachment\" (\"name\" \"att3\" \"filename\" \"10.jpg\")) NIL NIL) \"mixed\" (\"boundary\" \"----=_Part_537_1371134700.1410847112668\") NIL) RFC822.HEADER {3}\r\nx\r\n)\r\na001 OK FETCH complete\r\n";
@@ -169,8 +171,8 @@ VMIME_TEST_SUITE_BEGIN(IMAPParserTest)
// Support for NIL boundary, for mail.ru IMAP server:
// https://www.ietf.org/mail-archive/web/imapext/current/msg05442.html
- void testFETCHBodyStructure_NIL_body_fld_param_value()
- {
+ void testFETCHBodyStructure_NIL_body_fld_param_value() {
+
vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>();
diff --git a/tests/net/imap/IMAPTagTest.cpp b/tests/net/imap/IMAPTagTest.cpp
index db04537a..c8e09b6b 100644
--- a/tests/net/imap/IMAPTagTest.cpp
+++ b/tests/net/imap/IMAPTagTest.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
@@ -36,16 +36,16 @@ VMIME_TEST_SUITE_BEGIN(imapTagTest)
VMIME_TEST_LIST_END
- void testConstruct()
- {
+ void testConstruct() {
+
vmime::shared_ptr <vmime::net::imap::IMAPTag> tag =
vmime::make_shared <vmime::net::imap::IMAPTag>();
VASSERT_EQ("init", "a001", static_cast <vmime::string>(*tag));
}
- void testIncrement()
- {
+ void testIncrement() {
+
vmime::shared_ptr <vmime::net::imap::IMAPTag> tag =
vmime::make_shared <vmime::net::imap::IMAPTag>();
@@ -59,13 +59,14 @@ VMIME_TEST_SUITE_BEGIN(imapTagTest)
VASSERT_EQ("init", "a004", static_cast <vmime::string>(*tag));
}
- void testReset()
- {
+ void testReset() {
+
vmime::shared_ptr <vmime::net::imap::IMAPTag> tag =
vmime::make_shared <vmime::net::imap::IMAPTag>();
- for (int i = tag->number() ; i < tag->maximumNumber() ; ++i)
+ for (int i = tag->number() ; i < tag->maximumNumber() ; ++i) {
(*tag)++;
+ }
VASSERT_EQ("last", "Z999", static_cast <vmime::string>(*tag));
@@ -74,13 +75,14 @@ VMIME_TEST_SUITE_BEGIN(imapTagTest)
VASSERT_EQ("reset", "a001", static_cast <vmime::string>(*tag));
}
- void testNumber()
- {
+ void testNumber() {
+
vmime::shared_ptr <vmime::net::imap::IMAPTag> tag =
vmime::make_shared <vmime::net::imap::IMAPTag>();
- for (int i = 0 ; i < 41 ; ++i)
+ for (int i = 0 ; i < 41 ; ++i) {
(*tag)++;
+ }
VASSERT_EQ("number", 42, tag->number());
}
diff --git a/tests/net/imap/IMAPUtilsTest.cpp b/tests/net/imap/IMAPUtilsTest.cpp
index db88b539..b707fd06 100644
--- a/tests/net/imap/IMAPUtilsTest.cpp
+++ b/tests/net/imap/IMAPUtilsTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2014 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
@@ -46,8 +46,8 @@ VMIME_TEST_SUITE_BEGIN(IMAPUtilsTest)
VMIME_TEST_LIST_END
- void testQuoteString()
- {
+ void testQuoteString() {
+
VASSERT_EQ("unquoted", "ascii", IMAPUtils::quoteString("ascii"));
VASSERT_EQ("space", "\"ascii with space\"", IMAPUtils::quoteString("ascii with space"));
@@ -63,8 +63,8 @@ VMIME_TEST_SUITE_BEGIN(IMAPUtilsTest)
}
- void testToModifiedUTF7()
- {
+ void testToModifiedUTF7() {
+
#define FC(x) vmime::net::folder::path::component(x, vmime::charsets::UTF_8)
// Example strings from RFC-1642 (modified for IMAP UTF-7)
@@ -80,8 +80,8 @@ VMIME_TEST_SUITE_BEGIN(IMAPUtilsTest)
#undef FC
}
- void testFromModifiedUTF7()
- {
+ void testFromModifiedUTF7() {
+
#define FC(x) vmime::net::folder::path::component(x, vmime::charsets::UTF_8)
// Example strings from RFC-1642 (modified for IMAP UTF-7)
@@ -97,8 +97,8 @@ VMIME_TEST_SUITE_BEGIN(IMAPUtilsTest)
#undef FC
}
- void testConvertAddressList()
- {
+ void testConvertAddressList() {
+
IMAPParser parser;
IMAPParser::address_list addrList;
@@ -117,8 +117,8 @@ VMIME_TEST_SUITE_BEGIN(IMAPUtilsTest)
VASSERT_EQ("mbox-2", "name2", mboxList.getMailboxAt(1)->getName().getWholeBuffer());
}
- void testMessageFlagList()
- {
+ void testMessageFlagList() {
+
int flags = 0;
std::vector <vmime::string> flagList;
@@ -158,14 +158,14 @@ VMIME_TEST_SUITE_BEGIN(IMAPUtilsTest)
VASSERT("2.found2", std::find(flagList.begin(), flagList.end(), "\\Seen") != flagList.end());
}
- void testDateTime()
- {
+ void testDateTime() {
+
vmime::datetime dt(2014, 3, 17, 23, 26, 22, vmime::datetime::GMT2);
VASSERT_EQ("datetime", "\"17-Mar-2014 23:26:22 +0200\"", IMAPUtils::dateTime(dt));
}
- void testPathToString()
- {
+ void testPathToString() {
+
#define FC(x) vmime::net::folder::path::component(x, vmime::charsets::UTF_8)
vmime::net::folder::path path;
@@ -177,8 +177,8 @@ VMIME_TEST_SUITE_BEGIN(IMAPUtilsTest)
#undef FC
}
- void testStringToPath()
- {
+ void testStringToPath() {
+
#define FC(x) vmime::net::folder::path::component(x, vmime::charsets::UTF_8)
vmime::net::folder::path path = IMAPUtils::stringToPath('/', "Hi Mum &Jjo-!/&ZeVnLIqe-");
@@ -190,8 +190,8 @@ VMIME_TEST_SUITE_BEGIN(IMAPUtilsTest)
#undef FC
}
- void testBuildFetchCommand()
- {
+ void testBuildFetchCommand() {
+
vmime::shared_ptr <IMAPConnection> cnt;
vmime::net::messageSet msgs = vmime::net::messageSet::byNumber(42);
diff --git a/tests/net/maildir/maildirStoreTest.cpp b/tests/net/maildir/maildirStoreTest.cpp
index 11868c9d..1f418e81 100644
--- a/tests/net/maildir/maildirStoreTest.cpp
+++ b/tests/net/maildir/maildirStoreTest.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
@@ -37,8 +37,8 @@ typedef vmime::net::folder::path fpath;
typedef vmime::net::folder::path::component fpathc;
-const fpath operator/(const fpath& path, const std::string& c)
-{
+const fpath operator/(const fpath& path, const std::string& c) {
+
return path / fpathc(c);
}
@@ -65,8 +65,7 @@ static const vmime::string TEST_MESSAGE_1 =
*/
// KMail format
-static const vmime::string TEST_MAILDIR_KMAIL[] = // directories to create
-{
+static const vmime::string TEST_MAILDIR_KMAIL[] = { // directories to create
"/Folder",
"/Folder/new",
"/Folder/tmp",
@@ -92,15 +91,13 @@ static const vmime::string TEST_MAILDIR_KMAIL[] = // directories to create
"*" // end
};
-static const vmime::string TEST_MAILDIRFILES_KMAIL[] = // files to create and their contents
-{
+static const vmime::string TEST_MAILDIRFILES_KMAIL[] = { // files to create and their contents
"/.Folder.directory/.SubFolder.directory/SubSubFolder2/cur/1043236113.351.EmqD:S", TEST_MESSAGE_1,
"*" // end
};
// Courier format
-static const vmime::string TEST_MAILDIR_COURIER[] = // directories to create
-{
+static const vmime::string TEST_MAILDIR_COURIER[] = { // directories to create
"/.Folder",
"/.Folder/new",
"/.Folder/tmp",
@@ -125,8 +122,7 @@ static const vmime::string TEST_MAILDIR_COURIER[] = // directories to create
"*" // end
};
-static const vmime::string TEST_MAILDIRFILES_COURIER[] = // files to create and their contents
-{
+static const vmime::string TEST_MAILDIRFILES_COURIER[] = { // files to create and their contents
"/.Folder/maildirfolder", "",
"/.Folder.SubFolder/maildirfolder", "",
"/.Folder.SubFolder.SubSubFolder1/maildirfolder", "",
@@ -169,22 +165,22 @@ VMIME_TEST_SUITE_BEGIN(maildirStoreTest)
public:
- maildirStoreTest()
- {
+ maildirStoreTest() {
+
// Temporary directory
m_tempPath = fspath() / fspathc("tmp") // Use /tmp
/ fspathc("vmime" + vmime::utility::stringUtils::toString(std::time(NULL))
+ vmime::utility::stringUtils::toString(std::rand()));
}
- void tearDown()
- {
+ void tearDown() {
+
// In case of an uncaught exception
destroyMaildir();
}
- void testDetectFormat_KMail()
- {
+ void testDetectFormat_KMail() {
+
createMaildir(TEST_MAILDIR_KMAIL, TEST_MAILDIRFILES_KMAIL);
vmime::shared_ptr <vmime::net::maildir::maildirStore> store =
@@ -195,8 +191,8 @@ public:
destroyMaildir();
}
- void testDetectFormat_Courier()
- {
+ void testDetectFormat_Courier() {
+
createMaildir(TEST_MAILDIR_COURIER, TEST_MAILDIRFILES_COURIER);
vmime::shared_ptr <vmime::net::maildir::maildirStore> store =
@@ -208,18 +204,18 @@ public:
}
- void testListRootFolders_KMail()
- {
+ void testListRootFolders_KMail() {
+
testListRootFoldersImpl(TEST_MAILDIR_KMAIL, TEST_MAILDIRFILES_KMAIL);
}
- void testListRootFolders_Courier()
- {
+ void testListRootFolders_Courier() {
+
testListRootFoldersImpl(TEST_MAILDIR_COURIER, TEST_MAILDIRFILES_COURIER);
}
- void testListRootFoldersImpl(const vmime::string* const dirs, const vmime::string* const files)
- {
+ void testListRootFoldersImpl(const vmime::string* const dirs, const vmime::string* const files) {
+
createMaildir(dirs, files);
// Connect to store
@@ -238,18 +234,18 @@ public:
}
- void testListAllFolders_KMail()
- {
+ void testListAllFolders_KMail() {
+
testListAllFoldersImpl(TEST_MAILDIR_KMAIL, TEST_MAILDIRFILES_KMAIL);
}
- void testListAllFolders_Courier()
- {
+ void testListAllFolders_Courier() {
+
testListAllFoldersImpl(TEST_MAILDIR_COURIER, TEST_MAILDIRFILES_COURIER);
}
- void testListAllFoldersImpl(const vmime::string* const dirs, const vmime::string* const files)
- {
+ void testListAllFoldersImpl(const vmime::string* const dirs, const vmime::string* const files) {
+
createMaildir(dirs, files);
// Connect to store
@@ -271,25 +267,26 @@ public:
}
- void testListMessages_KMail()
- {
+ void testListMessages_KMail() {
+
testListMessagesImpl(TEST_MAILDIR_KMAIL, TEST_MAILDIRFILES_KMAIL);
}
- void testListMessages_Courier()
- {
+ void testListMessages_Courier() {
+
testListMessagesImpl(TEST_MAILDIR_COURIER, TEST_MAILDIRFILES_COURIER);
}
- void testListMessagesImpl(const vmime::string* const dirs, const vmime::string* const files)
- {
+ void testListMessagesImpl(const vmime::string* const dirs, const vmime::string* const files) {
+
createMaildir(dirs, files);
vmime::shared_ptr <vmime::net::store> store = createAndConnectStore();
vmime::shared_ptr <vmime::net::folder> rootFolder = store->getRootFolder();
- vmime::shared_ptr <vmime::net::folder> folder = store->getFolder
- (fpath() / "Folder" / "SubFolder" / "SubSubFolder2");
+ vmime::shared_ptr <vmime::net::folder> folder = store->getFolder(
+ fpath() / "Folder" / "SubFolder" / "SubSubFolder2"
+ );
vmime::size_t count, unseen;
folder->status(count, unseen);
@@ -316,14 +313,14 @@ public:
}
- void testRenameFolder_KMail()
- {
- try
- {
+ void testRenameFolder_KMail() {
+
+ try {
+
testRenameFolderImpl(TEST_MAILDIR_KMAIL, TEST_MAILDIRFILES_KMAIL);
- }
- catch (vmime::exception& e)
- {
+
+ } catch (vmime::exception& e) {
+
std::cerr << e;
throw e;
}
@@ -331,27 +328,27 @@ public:
void testRenameFolder_Courier()
{
- try
- {
+ try {
+
testRenameFolderImpl(TEST_MAILDIR_COURIER, TEST_MAILDIRFILES_COURIER);
- }
- catch (vmime::exception& e)
- {
+
+ } catch (vmime::exception& e) {
+
std::cerr << e;
throw e;
}
}
- void testRenameFolderImpl(const vmime::string* const dirs, const vmime::string* const files)
- {
+ void testRenameFolderImpl(const vmime::string* const dirs, const vmime::string* const files) {
+
createMaildir(dirs, files);
vmime::shared_ptr <vmime::net::store> store = createAndConnectStore();
vmime::shared_ptr <vmime::net::folder> rootFolder = store->getRootFolder();
// Rename "Folder/SubFolder" to "Folder/foo"
- vmime::shared_ptr <vmime::net::folder> folder = store->getFolder
- (fpath() / "Folder" / "SubFolder");
+ vmime::shared_ptr <vmime::net::folder> folder =
+ store->getFolder(fpath() / "Folder" / "SubFolder");
folder->rename(fpath() / "Folder" / "foo");
@@ -373,26 +370,26 @@ public:
}
- void testDestroyFolder_KMail()
- {
+ void testDestroyFolder_KMail() {
+
testDestroyFolderImpl(TEST_MAILDIR_KMAIL, TEST_MAILDIRFILES_KMAIL);
}
- void testDestroyFolder_Courier()
- {
+ void testDestroyFolder_Courier() {
+
testDestroyFolderImpl(TEST_MAILDIR_COURIER, TEST_MAILDIRFILES_COURIER);
}
- void testDestroyFolderImpl(const vmime::string* const dirs, const vmime::string* const files)
- {
+ void testDestroyFolderImpl(const vmime::string* const dirs, const vmime::string* const files) {
+
createMaildir(dirs, files);
vmime::shared_ptr <vmime::net::store> store = createAndConnectStore();
vmime::shared_ptr <vmime::net::folder> rootFolder = store->getRootFolder();
// Destroy "Folder/SubFolder" (total: 3 folders)
- vmime::shared_ptr <vmime::net::folder> folder = store->getFolder
- (fpath() / "Folder" / "SubFolder");
+ vmime::shared_ptr <vmime::net::folder> folder =
+ store->getFolder(fpath() / "Folder" / "SubFolder");
folder->destroy();
@@ -411,18 +408,18 @@ public:
}
- void testFolderExists_KMail()
- {
+ void testFolderExists_KMail() {
+
testFolderExistsImpl(TEST_MAILDIR_KMAIL, TEST_MAILDIRFILES_KMAIL);
}
- void testFolderExists_Courier()
- {
+ void testFolderExists_Courier() {
+
testFolderExistsImpl(TEST_MAILDIR_COURIER, TEST_MAILDIRFILES_COURIER);
}
- void testFolderExistsImpl(const vmime::string* const dirs, const vmime::string* const files)
- {
+ void testFolderExistsImpl(const vmime::string* const dirs, const vmime::string* const files) {
+
createMaildir(dirs, files);
vmime::shared_ptr <vmime::net::store> store = createAndConnectStore();
@@ -437,18 +434,18 @@ public:
}
- void testCreateFolder_KMail()
- {
+ void testCreateFolder_KMail() {
+
testCreateFolderImpl(TEST_MAILDIR_KMAIL, TEST_MAILDIRFILES_KMAIL);
}
- void testCreateFolder_Courier()
- {
+ void testCreateFolder_Courier() {
+
testCreateFolderImpl(TEST_MAILDIR_COURIER, TEST_MAILDIRFILES_COURIER);
}
- void testCreateFolderImpl(const vmime::string* const dirs, const vmime::string* const files)
- {
+ void testCreateFolderImpl(const vmime::string* const dirs, const vmime::string* const files) {
+
createMaildir(dirs, files);
vmime::shared_ptr <vmime::net::store> store = createAndConnectStore();
@@ -471,8 +468,8 @@ private:
vmime::utility::file::path m_tempPath;
- vmime::shared_ptr <vmime::net::store> createAndConnectStore()
- {
+ vmime::shared_ptr <vmime::net::store> createAndConnectStore() {
+
vmime::shared_ptr <vmime::net::session> session = vmime::net::session::create();
vmime::shared_ptr <vmime::net::store> store =
@@ -483,21 +480,23 @@ private:
return store;
}
- const vmime::shared_ptr <vmime::net::folder> findFolder
- (const std::vector <vmime::shared_ptr <vmime::net::folder> >& folders,
- const vmime::net::folder::path& path)
- {
- for (size_t i = 0, n = folders.size() ; i < n ; ++i)
- {
- if (folders[i]->getFullPath() == path)
+ const vmime::shared_ptr <vmime::net::folder> findFolder(
+ const std::vector <vmime::shared_ptr <vmime::net::folder> >& folders,
+ const vmime::net::folder::path& path
+ ) {
+
+ for (size_t i = 0, n = folders.size() ; i < n ; ++i) {
+
+ if (folders[i]->getFullPath() == path) {
return folders[i];
+ }
}
return vmime::null;
}
- const vmime::utility::url getStoreURL()
- {
+ const vmime::utility::url getStoreURL() {
+
vmime::shared_ptr <vmime::utility::fileSystemFactory> fsf =
vmime::platform::getHandler()->getFileSystemFactory();
@@ -507,22 +506,22 @@ private:
return url;
}
- void createMaildir(const vmime::string* const dirs, const vmime::string* const files)
- {
+ void createMaildir(const vmime::string* const dirs, const vmime::string* const files) {
+
vmime::shared_ptr <vmime::utility::fileSystemFactory> fsf =
vmime::platform::getHandler()->getFileSystemFactory();
vmime::shared_ptr <vmime::utility::file> rootDir = fsf->create(m_tempPath);
rootDir->createDirectory(false);
- for (vmime::string const* dir = dirs ; *dir != "*" ; ++dir)
- {
+ for (vmime::string const* dir = dirs ; *dir != "*" ; ++dir) {
+
vmime::shared_ptr <vmime::utility::file> fdir = fsf->create(m_tempPath / fsf->stringToPath(*dir));
fdir->createDirectory(false);
}
- for (vmime::string const* file = files ; *file != "*" ; file += 2)
- {
+ for (vmime::string const* file = files ; *file != "*" ; file += 2) {
+
const vmime::string& contents = *(file + 1);
vmime::shared_ptr <vmime::utility::file> ffile = fsf->create(m_tempPath / fsf->stringToPath(*file));
@@ -539,53 +538,47 @@ private:
}
- void destroyMaildir()
- {
+ void destroyMaildir() {
+
vmime::shared_ptr <vmime::utility::fileSystemFactory> fsf =
vmime::platform::getHandler()->getFileSystemFactory();
recursiveDelete(fsf->create(m_tempPath));
}
- void recursiveDelete(vmime::shared_ptr <vmime::utility::file> dir)
- {
- if (!dir->exists() || !dir->isDirectory())
+ void recursiveDelete(vmime::shared_ptr <vmime::utility::file> dir) {
+
+ if (!dir->exists() || !dir->isDirectory()) {
return;
+ }
vmime::shared_ptr <vmime::utility::fileIterator> files = dir->getFiles();
// First, delete files and subdirectories in this directory
- while (files->hasMoreElements())
- {
+ while (files->hasMoreElements()) {
+
vmime::shared_ptr <vmime::utility::file> file = files->nextElement();
- if (file->isDirectory())
- {
+ if (file->isDirectory()) {
+
recursiveDelete(file);
- }
- else
- {
- try
- {
+
+ } else {
+
+ try {
file->remove();
- }
- catch (vmime::exceptions::filesystem_exception&)
- {
+ } catch (vmime::exceptions::filesystem_exception&) {
// Ignore
}
}
}
// Then, delete this (empty) directory
- try
- {
+ try {
dir->remove();
- }
- catch (vmime::exceptions::filesystem_exception&)
- {
+ } catch (vmime::exceptions::filesystem_exception&) {
// Ignore
}
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/net/maildir/maildirUtilsTest.cpp b/tests/net/maildir/maildirUtilsTest.cpp
index 3538d4a8..9deeebfa 100644
--- a/tests/net/maildir/maildirUtilsTest.cpp
+++ b/tests/net/maildir/maildirUtilsTest.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
@@ -36,11 +36,13 @@ VMIME_TEST_SUITE_BEGIN(maildirUtilsTest)
VMIME_TEST_LIST_END
- void testMessageSetToNumberList()
- {
+ void testMessageSetToNumberList() {
+
const std::vector <size_t> msgNums =
- maildirUtils::messageSetToNumberList
- (vmime::net::messageSet::byNumber(5, -1), /* msgCount */ 8);
+ maildirUtils::messageSetToNumberList(
+ vmime::net::messageSet::byNumber(5, -1),
+ /* msgCount */ 8
+ );
VASSERT_EQ("Count", 4, msgNums.size());
VASSERT_EQ("1", 5, msgNums[0]);
@@ -50,4 +52,3 @@ VMIME_TEST_SUITE_BEGIN(maildirUtilsTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/net/messageSetTest.cpp b/tests/net/messageSetTest.cpp
index 4d129663..dee5dc81 100644
--- a/tests/net/messageSetTest.cpp
+++ b/tests/net/messageSetTest.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
@@ -46,47 +46,51 @@ VMIME_TEST_SUITE_BEGIN(messageSetTest)
VMIME_TEST_LIST_END
- class messageSetStringEnumerator : public vmime::net::messageSetEnumerator
- {
+ class messageSetStringEnumerator : public vmime::net::messageSetEnumerator {
+
public:
messageSetStringEnumerator()
- : m_first(true)
- {
+ : m_first(true) {
+
}
- void enumerateNumberMessageRange(const vmime::net::numberMessageRange& range)
- {
- if (!m_first)
+ void enumerateNumberMessageRange(const vmime::net::numberMessageRange& range) {
+
+ if (!m_first) {
m_oss << ",";
+ }
- if (range.getFirst() == range.getLast())
+ if (range.getFirst() == range.getLast()) {
m_oss << range.getFirst();
- else if (range.getLast() == size_t(-1))
+ } else if (range.getLast() == size_t(-1)) {
m_oss << range.getFirst() << ":(LAST)";
- else
+ } else {
m_oss << range.getFirst() << ":" << range.getLast();
+ }
m_first = false;
}
- void enumerateUIDMessageRange(const vmime::net::UIDMessageRange& range)
- {
- if (!m_first)
+ void enumerateUIDMessageRange(const vmime::net::UIDMessageRange& range) {
+
+ if (!m_first) {
m_oss << ",";
+ }
- if (range.getFirst() == range.getLast())
+ if (range.getFirst() == range.getLast()) {
m_oss << range.getFirst();
- else if (range.getLast() == size_t(-1))
+ } else if (range.getLast() == size_t(-1)) {
m_oss << range.getFirst() << ":(LAST)";
- else
+ } else {
m_oss << range.getFirst() << ":" << range.getLast();
+ }
m_first = false;
}
- const std::string str() const
- {
+ const std::string str() const {
+
return m_oss.str();
}
@@ -97,8 +101,8 @@ VMIME_TEST_SUITE_BEGIN(messageSetTest)
};
- const std::string enumerateAsString(const vmime::net::messageSet& set)
- {
+ const std::string enumerateAsString(const vmime::net::messageSet& set) {
+
messageSetStringEnumerator en;
set.enumerate(en);
@@ -106,33 +110,33 @@ VMIME_TEST_SUITE_BEGIN(messageSetTest)
}
- void testNumberSet_Single()
- {
+ void testNumberSet_Single() {
+
VASSERT_EQ("str", "42", enumerateAsString(vmime::net::messageSet::byNumber(42)));
}
- void testNumberSet_Range()
- {
+ void testNumberSet_Range() {
+
VASSERT_EQ("str", "42:100", enumerateAsString(vmime::net::messageSet::byNumber(42, 100)));
}
- void testNumberSet_InvalidRange()
- {
+ void testNumberSet_InvalidRange() {
+
VASSERT_THROW("first > last", vmime::net::messageSet::byNumber(100, 42), std::invalid_argument);
}
- void testNumberSet_InvalidFirst()
- {
+ void testNumberSet_InvalidFirst() {
+
VASSERT_THROW("first == -1", vmime::net::messageSet::byNumber(-1, 42), std::invalid_argument);
}
- void testNumberSet_InfiniteRange()
- {
+ void testNumberSet_InfiniteRange() {
+
VASSERT_EQ("str", "42:(LAST)", enumerateAsString(vmime::net::messageSet::byNumber(42, -1)));
}
- void testNumberSet_Multiple()
- {
+ void testNumberSet_Multiple() {
+
std::vector <vmime::size_t> numbers;
numbers.push_back(1); // test grouping 1:3
numbers.push_back(89); // test sorting
@@ -151,23 +155,23 @@ VMIME_TEST_SUITE_BEGIN(messageSetTest)
}
- void testUIDSet_Single()
- {
+ void testUIDSet_Single() {
+
VASSERT_EQ("str", "abcdef", enumerateAsString(vmime::net::messageSet::byUID("abcdef")));
}
- void testUIDSet_Range()
- {
+ void testUIDSet_Range() {
+
VASSERT_EQ("str", "abc:def", enumerateAsString(vmime::net::messageSet::byUID("abc:def")));
}
- void testUIDSet_InfiniteRange()
- {
+ void testUIDSet_InfiniteRange() {
+
VASSERT_EQ("str", "abc:*", enumerateAsString(vmime::net::messageSet::byUID("abc", "*")));
}
- void testUIDSet_MultipleNumeric()
- {
+ void testUIDSet_MultipleNumeric() {
+
std::vector <vmime::net::message::uid> uids;
uids.push_back("1"); // test grouping 1:3
uids.push_back("89"); // test sorting
@@ -185,8 +189,8 @@ VMIME_TEST_SUITE_BEGIN(messageSetTest)
VASSERT_EQ("str", "1:3,42,53:57,89,99", enumerateAsString(vmime::net::messageSet::byUID(uids)));
}
- void testUIDSet_MultipleNonNumeric()
- {
+ void testUIDSet_MultipleNonNumeric() {
+
std::vector <vmime::net::message::uid> uids;
uids.push_back("12");
uids.push_back("34");
@@ -196,8 +200,8 @@ VMIME_TEST_SUITE_BEGIN(messageSetTest)
VASSERT_EQ("str", "12,34,ab56,78cd", enumerateAsString(vmime::net::messageSet::byUID(uids)));
}
- void testIsNumberSet()
- {
+ void testIsNumberSet() {
+
VASSERT_TRUE("number1", vmime::net::messageSet::byNumber(42).isNumberSet());
VASSERT_FALSE("uid1", vmime::net::messageSet::byUID("42").isNumberSet());
@@ -205,8 +209,8 @@ VMIME_TEST_SUITE_BEGIN(messageSetTest)
VASSERT_FALSE("uid2", vmime::net::messageSet::byUID("42", "*").isNumberSet());
}
- void testIsUIDSet()
- {
+ void testIsUIDSet() {
+
VASSERT_FALSE("number1", vmime::net::messageSet::byNumber(42).isUIDSet());
VASSERT_TRUE("uid1", vmime::net::messageSet::byUID("42").isUIDSet());
@@ -214,8 +218,8 @@ VMIME_TEST_SUITE_BEGIN(messageSetTest)
VASSERT_TRUE("uid2", vmime::net::messageSet::byUID("42", "*").isUIDSet());
}
- void testMixedRanges()
- {
+ void testMixedRanges() {
+
vmime::net::messageSet set = vmime::net::messageSet::byNumber(1, 5);
set.addRange(vmime::net::numberMessageRange(6, 8));
diff --git a/tests/net/pop3/POP3CommandTest.cpp b/tests/net/pop3/POP3CommandTest.cpp
index 139e948b..3ed579ee 100644
--- a/tests/net/pop3/POP3CommandTest.cpp
+++ b/tests/net/pop3/POP3CommandTest.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
@@ -58,174 +58,177 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest)
VMIME_TEST_LIST_END
- void testCreateCommand()
- {
+ void testCreateCommand() {
+
vmime::shared_ptr <POP3Command> cmd = POP3Command::createCommand("MY_COMMAND");
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "MY_COMMAND", cmd->getText());
}
- void testCreateCommandParams()
- {
+ void testCreateCommandParams() {
+
vmime::shared_ptr <POP3Command> cmd = POP3Command::createCommand("MY_COMMAND param1 param2");
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "MY_COMMAND param1 param2", cmd->getText());
}
- void testCAPA()
- {
+ void testCAPA() {
+
vmime::shared_ptr <POP3Command> cmd = POP3Command::CAPA();
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "CAPA", cmd->getText());
}
- void testNOOP()
- {
+ void testNOOP() {
+
vmime::shared_ptr <POP3Command> cmd = POP3Command::NOOP();
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "NOOP", cmd->getText());
}
- void testAUTH()
- {
+ void testAUTH() {
+
vmime::shared_ptr <POP3Command> cmd = POP3Command::AUTH("saslmechanism");
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "AUTH saslmechanism", cmd->getText());
}
- void testAUTH_InitialResponse()
- {
+ void testAUTH_InitialResponse() {
+
vmime::shared_ptr <POP3Command> cmd = POP3Command::AUTH("saslmechanism", "initial-response");
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "AUTH saslmechanism initial-response", cmd->getText());
}
- void testSTLS()
- {
+ void testSTLS() {
+
vmime::shared_ptr <POP3Command> cmd = POP3Command::STLS();
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "STLS", cmd->getText());
}
- void testAPOP()
- {
+ void testAPOP() {
+
vmime::shared_ptr <POP3Command> cmd = POP3Command::APOP("user", "digest");
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "APOP user digest", cmd->getText());
}
- void testUSER()
- {
+ void testUSER() {
+
vmime::shared_ptr <POP3Command> cmd = POP3Command::USER("user");
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "USER user", cmd->getText());
}
- void testPASS()
- {
+ void testPASS() {
+
vmime::shared_ptr <POP3Command> cmd = POP3Command::PASS("pass");
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "PASS pass", cmd->getText());
}
- void testSTAT()
- {
+ void testSTAT() {
+
vmime::shared_ptr <POP3Command> cmd = POP3Command::STAT();
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "STAT", cmd->getText());
}
- void testLIST()
- {
+ void testLIST() {
+
vmime::shared_ptr <POP3Command> cmd = POP3Command::LIST();
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "LIST", cmd->getText());
}
- void testLISTMessage()
- {
+ void testLISTMessage() {
+
vmime::shared_ptr <POP3Command> cmd = POP3Command::LIST(42);
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "LIST 42", cmd->getText());
}
- void testUIDL()
- {
+ void testUIDL() {
+
vmime::shared_ptr <POP3Command> cmd = POP3Command::UIDL();
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "UIDL", cmd->getText());
}
- void testUIDLMessage()
- {
+ void testUIDLMessage() {
+
vmime::shared_ptr <POP3Command> cmd = POP3Command::UIDL(42);
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "UIDL 42", cmd->getText());
}
- void testDELE()
- {
+ void testDELE() {
+
vmime::shared_ptr <POP3Command> cmd = POP3Command::DELE(42);
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "DELE 42", cmd->getText());
}
- void testRETR()
- {
+ void testRETR() {
+
vmime::shared_ptr <POP3Command> cmd = POP3Command::RETR(42);
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "RETR 42", cmd->getText());
}
- void testTOP()
- {
+ void testTOP() {
+
vmime::shared_ptr <POP3Command> cmd = POP3Command::TOP(42, 567);
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "TOP 42 567", cmd->getText());
}
- void testRSET()
- {
+ void testRSET() {
+
vmime::shared_ptr <POP3Command> cmd = POP3Command::RSET();
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "RSET", cmd->getText());
}
- void testQUIT()
- {
+ void testQUIT() {
+
vmime::shared_ptr <POP3Command> cmd = POP3Command::QUIT();
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "QUIT", cmd->getText());
}
- void testWriteToSocket()
- {
+ void testWriteToSocket() {
+
vmime::shared_ptr <POP3Command> cmd = POP3Command::createCommand("MY_COMMAND param1 param2");
vmime::shared_ptr <testSocket> sok = vmime::make_shared <testSocket>();
- vmime::shared_ptr <POP3ConnectionTest> conn = vmime::make_shared <POP3ConnectionTest>
- (vmime::dynamicCast <vmime::net::socket>(sok),
- vmime::shared_ptr <vmime::net::timeoutHandler>());
+
+ vmime::shared_ptr <POP3ConnectionTest> conn =
+ vmime::make_shared <POP3ConnectionTest>(
+ vmime::dynamicCast <vmime::net::socket>(sok),
+ vmime::shared_ptr <vmime::net::timeoutHandler>()
+ );
cmd->send(conn);
diff --git a/tests/net/pop3/POP3ResponseTest.cpp b/tests/net/pop3/POP3ResponseTest.cpp
index 2d3b3d32..8fecb749 100644
--- a/tests/net/pop3/POP3ResponseTest.cpp
+++ b/tests/net/pop3/POP3ResponseTest.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,13 +45,15 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest)
VMIME_TEST_LIST_END
- void testSingleLineResponseOK()
- {
+ void testSingleLineResponseOK() {
+
vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>();
- vmime::shared_ptr <POP3ConnectionTest> conn = vmime::make_shared <POP3ConnectionTest>
- (vmime::dynamicCast <vmime::net::socket>(socket), toh);
+ vmime::shared_ptr <POP3ConnectionTest> conn =
+ vmime::make_shared <POP3ConnectionTest>(
+ vmime::dynamicCast <vmime::net::socket>(socket), toh
+ );
socket->localSend("+OK Response Text\r\n");
@@ -65,13 +67,15 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest)
VASSERT_EQ("First Line", "+OK Response Text", resp->getFirstLine());
}
- void testSingleLineResponseERR()
- {
+ void testSingleLineResponseERR() {
+
vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>();
- vmime::shared_ptr <POP3ConnectionTest> conn = vmime::make_shared <POP3ConnectionTest>
- (vmime::dynamicCast <vmime::net::socket>(socket), toh);
+ vmime::shared_ptr <POP3ConnectionTest> conn =
+ vmime::make_shared <POP3ConnectionTest>(
+ vmime::dynamicCast <vmime::net::socket>(socket), toh
+ );
socket->localSend("-ERR Response Text\r\n");
@@ -85,13 +89,15 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest)
VASSERT_EQ("First Line", "-ERR Response Text", resp->getFirstLine());
}
- void testSingleLineResponseReady()
- {
+ void testSingleLineResponseReady() {
+
vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>();
- vmime::shared_ptr <POP3ConnectionTest> conn = vmime::make_shared <POP3ConnectionTest>
- (vmime::dynamicCast <vmime::net::socket>(socket), toh);
+ vmime::shared_ptr <POP3ConnectionTest> conn =
+ vmime::make_shared <POP3ConnectionTest>(
+ vmime::dynamicCast <vmime::net::socket>(socket), toh
+ );
socket->localSend("+ challenge_string\r\n");
@@ -105,8 +111,8 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest)
VASSERT_EQ("First Line", "+ challenge_string", resp->getFirstLine());
}
- void testSingleLineResponseInvalid()
- {
+ void testSingleLineResponseInvalid() {
+
vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>();
@@ -125,13 +131,15 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest)
VASSERT_EQ("First Line", "Invalid Response Text", resp->getFirstLine());
}
- void testSingleLineResponseLF()
- {
+ void testSingleLineResponseLF() {
+
vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>();
- vmime::shared_ptr <POP3ConnectionTest> conn = vmime::make_shared <POP3ConnectionTest>
- (vmime::dynamicCast <vmime::net::socket>(socket), toh);
+ vmime::shared_ptr <POP3ConnectionTest> conn =
+ vmime::make_shared <POP3ConnectionTest>(
+ vmime::dynamicCast <vmime::net::socket>(socket), toh
+ );
socket->localSend("+OK Response terminated by LF\n");
@@ -145,13 +153,15 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest)
VASSERT_EQ("First Line", "+OK Response terminated by LF", resp->getFirstLine());
}
- void testMultiLineResponse()
- {
+ void testMultiLineResponse() {
+
vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>();
- vmime::shared_ptr <POP3ConnectionTest> conn = vmime::make_shared <POP3ConnectionTest>
- (vmime::dynamicCast <vmime::net::socket>(socket), toh);
+ vmime::shared_ptr <POP3ConnectionTest> conn =
+ vmime::make_shared <POP3ConnectionTest>(
+ vmime::dynamicCast <vmime::net::socket>(socket), toh
+ );
socket->localSend("+OK Response Text\r\n");
socket->localSend("Line 1\r\n");
@@ -170,13 +180,15 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest)
VASSERT_EQ("Line 2", "Line 2", resp->getLineAt(1));
}
- void testMultiLineResponseLF()
- {
+ void testMultiLineResponseLF() {
+
vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>();
- vmime::shared_ptr <POP3ConnectionTest> conn = vmime::make_shared <POP3ConnectionTest>
- (vmime::dynamicCast <vmime::net::socket>(socket), toh);
+ vmime::shared_ptr <POP3ConnectionTest> conn =
+ vmime::make_shared <POP3ConnectionTest>(
+ vmime::dynamicCast <vmime::net::socket>(socket), toh
+ );
socket->localSend("+OK Response Text\n");
socket->localSend("Line 1\n");
@@ -195,18 +207,21 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest)
VASSERT_EQ("Line 2", "Line 2", resp->getLineAt(1));
}
- void testLargeResponse()
- {
+ void testLargeResponse() {
+
std::ostringstream data;
- for (unsigned int i = 0 ; i < 5000 ; ++i)
+ for (unsigned int i = 0 ; i < 5000 ; ++i) {
data << "VMIME.VMIME\nVMIME\r\nVMIME_VMIME";
+ }
vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>();
- vmime::shared_ptr <POP3ConnectionTest> conn = vmime::make_shared <POP3ConnectionTest>
- (vmime::dynamicCast <vmime::net::socket>(socket), toh);
+ vmime::shared_ptr <POP3ConnectionTest> conn =
+ vmime::make_shared <POP3ConnectionTest>(
+ vmime::dynamicCast <vmime::net::socket>(socket), toh
+ );
socket->localSend("+OK Large Response Follows\n");
socket->localSend(data.str());
@@ -227,4 +242,3 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/net/pop3/POP3StoreTest.cpp b/tests/net/pop3/POP3StoreTest.cpp
index a6818d46..5d9e3c20 100644
--- a/tests/net/pop3/POP3StoreTest.cpp
+++ b/tests/net/pop3/POP3StoreTest.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
@@ -37,8 +37,8 @@ VMIME_TEST_SUITE_BEGIN(POP3StoreTest)
VMIME_TEST_LIST_END
- void testCreateFromURL()
- {
+ void testCreateFromURL() {
+
vmime::shared_ptr <vmime::net::session> sess = vmime::net::session::create();
// POP3
@@ -54,8 +54,8 @@ VMIME_TEST_SUITE_BEGIN(POP3StoreTest)
VASSERT_TRUE("pop3s", typeid(*store2) == typeid(vmime::net::pop3::POP3SStore));
}
- void testConnectToInvalidServer()
- {
+ void testConnectToInvalidServer() {
+
vmime::shared_ptr <vmime::net::session> sess = vmime::net::session::create();
vmime::utility::url url("pop3://invalid-pop3-server");
diff --git a/tests/net/pop3/POP3TestUtils.hpp b/tests/net/pop3/POP3TestUtils.hpp
index b0ec09b8..24efb8b3 100644
--- a/tests/net/pop3/POP3TestUtils.hpp
+++ b/tests/net/pop3/POP3TestUtils.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
@@ -25,37 +25,40 @@
#include "vmime/net/pop3/POP3Store.hpp"
-class POP3TestStore : public vmime::net::pop3::POP3Store
-{
+class POP3TestStore : public vmime::net::pop3::POP3Store {
+
public:
POP3TestStore()
: POP3Store(vmime::net::session::create(),
- vmime::shared_ptr <vmime::security::authenticator>())
- {
+ vmime::shared_ptr <vmime::security::authenticator>()) {
+
}
};
-class POP3ConnectionTest : public vmime::net::pop3::POP3Connection
-{
+class POP3ConnectionTest : public vmime::net::pop3::POP3Connection {
+
public:
- POP3ConnectionTest(vmime::shared_ptr <vmime::net::socket> socket,
- vmime::shared_ptr <vmime::net::timeoutHandler> timeoutHandler)
+ POP3ConnectionTest(
+ vmime::shared_ptr <vmime::net::socket> socket,
+ vmime::shared_ptr <vmime::net::timeoutHandler> timeoutHandler
+ )
: POP3Connection(vmime::make_shared <POP3TestStore>(),
vmime::shared_ptr <vmime::security::authenticator>()),
- m_socket(socket), m_timeoutHandler(timeoutHandler)
- {
+ m_socket(socket),
+ m_timeoutHandler(timeoutHandler) {
+
}
- vmime::shared_ptr <vmime::net::socket> getSocket()
- {
+ vmime::shared_ptr <vmime::net::socket> getSocket() {
+
return m_socket;
}
- vmime::shared_ptr <vmime::net::timeoutHandler> getTimeoutHandler()
- {
+ vmime::shared_ptr <vmime::net::timeoutHandler> getTimeoutHandler() {
+
return m_timeoutHandler;
}
diff --git a/tests/net/pop3/POP3UtilsTest.cpp b/tests/net/pop3/POP3UtilsTest.cpp
index 36029eaa..1cded39b 100644
--- a/tests/net/pop3/POP3UtilsTest.cpp
+++ b/tests/net/pop3/POP3UtilsTest.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,13 +40,15 @@ VMIME_TEST_SUITE_BEGIN(POP3UtilsTest)
VMIME_TEST_LIST_END
- void testParseMultiListOrUidlResponse()
- {
+ void testParseMultiListOrUidlResponse() {
+
vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>();
- vmime::shared_ptr <POP3ConnectionTest> conn = vmime::make_shared <POP3ConnectionTest>
- (vmime::dynamicCast <vmime::net::socket>(socket), toh);
+ vmime::shared_ptr <POP3ConnectionTest> conn =
+ vmime::make_shared <POP3ConnectionTest>(
+ vmime::dynamicCast <vmime::net::socket>(socket), toh
+ );
socket->localSend("+OK Response Text\r\n");
socket->localSend("1 abcdef\r\n");
@@ -70,11 +72,11 @@ VMIME_TEST_SUITE_BEGIN(POP3UtilsTest)
VASSERT_EQ("5 (with extra space)", "yz", result[8]);
}
- void testMessageSetToNumberList()
- {
- const std::vector <size_t> msgNums =
- POP3Utils::messageSetToNumberList
- (vmime::net::messageSet::byNumber(5, -1), /* msgCount */ 8);
+ void testMessageSetToNumberList() {
+
+ const std::vector <size_t> msgNums = POP3Utils::messageSetToNumberList(
+ vmime::net::messageSet::byNumber(5, -1), /* msgCount */ 8
+ );
VASSERT_EQ("Count", 4, msgNums.size());
VASSERT_EQ("1", 5, msgNums[0]);
@@ -84,4 +86,3 @@ VMIME_TEST_SUITE_BEGIN(POP3UtilsTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/net/smtp/SMTPCommandSetTest.cpp b/tests/net/smtp/SMTPCommandSetTest.cpp
index f419eb40..7ea3578b 100644
--- a/tests/net/smtp/SMTPCommandSetTest.cpp
+++ b/tests/net/smtp/SMTPCommandSetTest.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
@@ -44,24 +44,24 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandSetTest)
VMIME_TEST_LIST_END
- void testCreate()
- {
+ void testCreate() {
+
vmime::shared_ptr <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ false);
VASSERT_NOT_NULL("Not null", cset);
VASSERT_FALSE("Finished", cset->isFinished());
}
- void testCreatePipeline()
- {
+ void testCreatePipeline() {
+
vmime::shared_ptr <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ true);
VASSERT_NOT_NULL("Not null", cset);
VASSERT_FALSE("Finished", cset->isFinished());
}
- void testAddCommand()
- {
+ void testAddCommand() {
+
vmime::shared_ptr <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ false);
VASSERT_NO_THROW("No throw 1", cset->addCommand(SMTPCommand::createCommand("MY_COMMAND1")));
@@ -82,8 +82,8 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandSetTest)
VASSERT_TRUE("Finished", cset->isFinished());
}
- void testAddCommandPipeline()
- {
+ void testAddCommandPipeline() {
+
vmime::shared_ptr <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ true);
VASSERT_NO_THROW("No throw 1", cset->addCommand(SMTPCommand::createCommand("MY_COMMAND1")));
@@ -105,8 +105,8 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandSetTest)
VASSERT_THROW("Throw", cset->addCommand(SMTPCommand::createCommand("MY_COMMAND3")), std::runtime_error);
}
- void testWriteToSocket()
- {
+ void testWriteToSocket() {
+
vmime::shared_ptr <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ false);
cset->addCommand(SMTPCommand::createCommand("MY_COMMAND1"));
@@ -127,8 +127,8 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandSetTest)
VASSERT_EQ("Receive cmd 2", "MY_COMMAND2\r\n", response);
}
- void testWriteToSocketPipeline()
- {
+ void testWriteToSocketPipeline() {
+
vmime::shared_ptr <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ true);
cset->addCommand(SMTPCommand::createCommand("MY_COMMAND1"));
@@ -144,8 +144,8 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandSetTest)
VASSERT_EQ("Receive cmds", "MY_COMMAND1\r\nMY_COMMAND2\r\n", response);
}
- void testGetLastCommandSent()
- {
+ void testGetLastCommandSent() {
+
vmime::shared_ptr <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ false);
cset->addCommand(SMTPCommand::createCommand("MY_COMMAND1"));
@@ -161,8 +161,8 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandSetTest)
VASSERT_EQ("Cmd 2", "MY_COMMAND2", cset->getLastCommandSent()->getText());
}
- void testGetLastCommandSentPipeline()
- {
+ void testGetLastCommandSentPipeline() {
+
vmime::shared_ptr <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ true);
cset->addCommand(SMTPCommand::createCommand("MY_COMMAND1"));
diff --git a/tests/net/smtp/SMTPCommandTest.cpp b/tests/net/smtp/SMTPCommandTest.cpp
index 9b3daa73..a0f03bb6 100644
--- a/tests/net/smtp/SMTPCommandTest.cpp
+++ b/tests/net/smtp/SMTPCommandTest.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
@@ -56,150 +56,157 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest)
VMIME_TEST_LIST_END
- void testCreateCommand()
- {
+ void testCreateCommand() {
+
vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::createCommand("MY_COMMAND");
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "MY_COMMAND", cmd->getText());
}
- void testCreateCommandParams()
- {
+ void testCreateCommandParams() {
+
vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::createCommand("MY_COMMAND param1 param2");
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "MY_COMMAND param1 param2", cmd->getText());
}
- void testHELO()
- {
+ void testHELO() {
+
vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::HELO("hostname");
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "HELO hostname", cmd->getText());
}
- void testEHLO()
- {
+ void testEHLO() {
+
vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::EHLO("hostname");
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "EHLO hostname", cmd->getText());
}
- void testAUTH()
- {
+ void testAUTH() {
+
vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::AUTH("saslmechanism");
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "AUTH saslmechanism", cmd->getText());
}
- void testAUTH_InitialResponse()
- {
+ void testAUTH_InitialResponse() {
+
vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::AUTH("saslmechanism", "initial-response");
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "AUTH saslmechanism initial-response", cmd->getText());
}
- void testSTARTTLS()
- {
+ void testSTARTTLS() {
+
vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::STARTTLS();
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "STARTTLS", cmd->getText());
}
- void testMAIL()
- {
+ void testMAIL() {
+
vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::MAIL(vmime::mailbox("[email protected]"), false);
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "MAIL FROM:<[email protected]>", cmd->getText());
}
- void testMAIL_Encoded()
- {
- vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::MAIL
- (vmime::mailbox(vmime::emailAddress("mailtest", "例え.テスト")), false);
+ void testMAIL_Encoded() {
+
+ vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::MAIL(
+ vmime::mailbox(vmime::emailAddress("mailtest", "例え.テスト")), false
+ );
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "MAIL FROM:<[email protected]>", cmd->getText());
}
- void testMAIL_UTF8()
- {
- vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::MAIL
- (vmime::mailbox(vmime::emailAddress("mailtest", "例え.テスト")), true);
+ void testMAIL_UTF8() {
+
+ vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::MAIL(
+ vmime::mailbox(vmime::emailAddress("mailtest", "例え.テスト")), true
+ );
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "MAIL FROM:<mailtest@例え.テスト> SMTPUTF8", cmd->getText());
}
- void testMAIL_SIZE()
- {
- vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::MAIL
- (vmime::mailbox("[email protected]"), false, 123456789);
+ void testMAIL_SIZE() {
+
+ vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::MAIL(
+ vmime::mailbox("[email protected]"), false, 123456789
+ );
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "MAIL FROM:<[email protected]> SIZE=123456789", cmd->getText());
}
- void testMAIL_SIZE_UTF8()
- {
- vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::MAIL
- (vmime::mailbox(vmime::emailAddress("mailtest", "例え.テスト")), true, 123456789);
+ void testMAIL_SIZE_UTF8() {
+
+ vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::MAIL(
+ vmime::mailbox(vmime::emailAddress("mailtest", "例え.テスト")), true, 123456789
+ );
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "MAIL FROM:<mailtest@例え.テスト> SMTPUTF8 SIZE=123456789", cmd->getText());
}
- void testRCPT()
- {
- vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::RCPT(vmime::mailbox("[email protected]"), false);
+ void testRCPT() {
+
+ vmime::shared_ptr <SMTPCommand> cmd =
+ SMTPCommand::RCPT(vmime::mailbox("[email protected]"), false);
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "RCPT TO:<[email protected]>", cmd->getText());
}
- void testRCPT_Encoded()
- {
- vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::RCPT
- (vmime::mailbox(vmime::emailAddress("mailtest", "例え.テスト")), false);
+ void testRCPT_Encoded() {
+
+ vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::RCPT(
+ vmime::mailbox(vmime::emailAddress("mailtest", "例え.テスト")), false
+ );
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "RCPT TO:<[email protected]>", cmd->getText());
}
- void testRCPT_UTF8()
- {
- vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::RCPT
- (vmime::mailbox(vmime::emailAddress("mailtest", "例え.テスト")), true);
+ void testRCPT_UTF8() {
+
+ vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::RCPT(
+ vmime::mailbox(vmime::emailAddress("mailtest", "例え.テスト")), true
+ );
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "RCPT TO:<mailtest@例え.テスト>", cmd->getText());
}
- void testRSET()
- {
+ void testRSET() {
+
vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::RSET();
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "RSET", cmd->getText());
}
- void testDATA()
- {
+ void testDATA() {
+
vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::DATA();
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "DATA", cmd->getText());
}
- void testBDAT()
- {
+ void testBDAT() {
+
vmime::shared_ptr <SMTPCommand> cmd1 = SMTPCommand::BDAT(12345, false);
VASSERT_NOT_NULL("Not null", cmd1);
@@ -211,24 +218,24 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest)
VASSERT_EQ("Text", "BDAT 67890 LAST", cmd2->getText());
}
- void testNOOP()
- {
+ void testNOOP() {
+
vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::NOOP();
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "NOOP", cmd->getText());
}
- void testQUIT()
- {
+ void testQUIT() {
+
vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::QUIT();
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "QUIT", cmd->getText());
}
- void testWriteToSocket()
- {
+ void testWriteToSocket() {
+
vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::createCommand("MY_COMMAND param1 param2");
vmime::shared_ptr <vmime::net::tracer> tracer;
diff --git a/tests/net/smtp/SMTPResponseTest.cpp b/tests/net/smtp/SMTPResponseTest.cpp
index d47e31e9..f899a828 100644
--- a/tests/net/smtp/SMTPResponseTest.cpp
+++ b/tests/net/smtp/SMTPResponseTest.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,12 +41,11 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest)
VMIME_TEST_LIST_END
- void testSingleLineResponse()
- {
+ void testSingleLineResponse() {
+
vmime::shared_ptr <vmime::net::tracer> tracer;
vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
- vmime::shared_ptr <vmime::net::timeoutHandler> toh =
- vmime::make_shared <testTimeoutHandler>();
+ vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>();
socket->localSend("123 Response Text\r\n");
@@ -60,12 +59,11 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest)
VASSERT_EQ("Text", "Response Text", resp->getText());
}
- void testSingleLineResponseLF()
- {
+ void testSingleLineResponseLF() {
+
vmime::shared_ptr <vmime::net::tracer> tracer;
vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
- vmime::shared_ptr <vmime::net::timeoutHandler> toh =
- vmime::make_shared <testTimeoutHandler>();
+ vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>();
socket->localSend("123 Response Text\n");
@@ -79,15 +77,13 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest)
VASSERT_EQ("Text", "Response Text", resp->getText());
}
- void testMultiLineResponse()
- {
+ void testMultiLineResponse() {
+
vmime::shared_ptr <vmime::net::tracer> tracer;
vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
- vmime::shared_ptr <vmime::net::timeoutHandler> toh =
- vmime::make_shared <testTimeoutHandler>();
+ vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>();
- socket->localSend
- (
+ socket->localSend(
"123-Response\r\n"
"123 Text\r\n"
);
@@ -108,15 +104,13 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest)
VASSERT_EQ("Text", "Text", resp->getLineAt(1).getText());
}
- void testMultiLineResponseDifferentCode()
- {
+ void testMultiLineResponseDifferentCode() {
+
vmime::shared_ptr <vmime::net::tracer> tracer;
vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
- vmime::shared_ptr <vmime::net::timeoutHandler> toh =
- vmime::make_shared <testTimeoutHandler>();
+ vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>();
- socket->localSend
- (
+ socket->localSend(
"123-Response\r\n"
"456 Text\r\n"
);
@@ -137,15 +131,13 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest)
VASSERT_EQ("Text", "Text", resp->getLineAt(1).getText());
}
- void testIncompleteMultiLineResponse()
- {
+ void testIncompleteMultiLineResponse() {
+
vmime::shared_ptr <vmime::net::tracer> tracer;
vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
- vmime::shared_ptr <vmime::net::timeoutHandler> toh =
- vmime::make_shared <testTimeoutHandler>(1);
+ vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>(1);
- socket->localSend
- (
+ socket->localSend(
"123-Response\r\n"
"123-Text\r\n"
// Missing data
@@ -153,20 +145,20 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest)
vmime::net::smtp::SMTPResponse::state responseState;
- VASSERT_THROW("Incomplete response",
+ VASSERT_THROW(
+ "Incomplete response",
vmime::net::smtp::SMTPResponse::readResponse(tracer, socket, toh, responseState),
- vmime::exceptions::operation_timed_out);
+ vmime::exceptions::operation_timed_out
+ );
}
- void testNoResponseText()
- {
+ void testNoResponseText() {
+
vmime::shared_ptr <vmime::net::tracer> tracer;
vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
- vmime::shared_ptr <vmime::net::timeoutHandler> toh =
- vmime::make_shared <testTimeoutHandler>(1);
+ vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>(1);
- socket->localSend
- (
+ socket->localSend(
"250\r\n"
);
@@ -180,12 +172,11 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest)
VASSERT_EQ("Text", "", resp->getText());
}
- void testEnhancedStatusCode()
- {
+ void testEnhancedStatusCode() {
+
vmime::shared_ptr <vmime::net::tracer> tracer;
vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
- vmime::shared_ptr <vmime::net::timeoutHandler> toh =
- vmime::make_shared <testTimeoutHandler>();
+ vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>();
socket->localSend("250 2.1.5 OK fu13sm4720601wic.7 - gsmtp\r\n");
@@ -202,12 +193,11 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest)
VASSERT_EQ("Enh.detail", 5, resp->getEnhancedCode().detail);
}
- void testNoEnhancedStatusCode()
- {
+ void testNoEnhancedStatusCode() {
+
vmime::shared_ptr <vmime::net::tracer> tracer;
vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
- vmime::shared_ptr <vmime::net::timeoutHandler> toh =
- vmime::make_shared <testTimeoutHandler>();
+ vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>();
socket->localSend("354 Go ahead fu13sm4720601wic.7 - gsmtp\r\n");
@@ -224,12 +214,11 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest)
VASSERT_EQ("Enh.detail", 0, resp->getEnhancedCode().detail);
}
- void testInvalidEnhancedStatusCode()
- {
+ void testInvalidEnhancedStatusCode() {
+
vmime::shared_ptr <vmime::net::tracer> tracer;
vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
- vmime::shared_ptr <vmime::net::timeoutHandler> toh =
- vmime::make_shared <testTimeoutHandler>();
+ vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>();
socket->localSend("250 4.2 xxx\r\n");
@@ -247,4 +236,3 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/net/smtp/SMTPTransportTest.cpp b/tests/net/smtp/SMTPTransportTest.cpp
index cbfab4f5..8ea4ba75 100644
--- a/tests/net/smtp/SMTPTransportTest.cpp
+++ b/tests/net/smtp/SMTPTransportTest.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,21 +33,19 @@
VMIME_TEST_SUITE_BEGIN(SMTPTransportTest)
VMIME_TEST_LIST_BEGIN
-/*
VMIME_TEST(testConnectToInvalidServer)
VMIME_TEST(testGreetingError)
VMIME_TEST(testMAILandRCPT)
VMIME_TEST(testChunking)
VMIME_TEST(testSize_Chunking)
VMIME_TEST(testSize_NoChunking)
-*/
VMIME_TEST(testSMTPUTF8_available)
VMIME_TEST(testSMTPUTF8_notAvailable)
VMIME_TEST_LIST_END
- void testConnectToInvalidServer()
- {
+ void testConnectToInvalidServer() {
+
vmime::shared_ptr <vmime::net::session> sess = vmime::net::session::create();
vmime::utility::url url("smtp://invalid-smtp-server");
@@ -56,26 +54,29 @@ VMIME_TEST_SUITE_BEGIN(SMTPTransportTest)
VASSERT_THROW("connect", store->connect(), vmime::exceptions::connection_error);
}
- void testGreetingError()
- {
+ void testGreetingError() {
+
vmime::shared_ptr <vmime::net::session> session = vmime::net::session::create();
- vmime::shared_ptr <vmime::net::transport> tr = session->getTransport
- (vmime::utility::url("smtp://localhost"));
+ vmime::shared_ptr <vmime::net::transport> tr =
+ session->getTransport(vmime::utility::url("smtp://localhost"));
tr->setSocketFactory(vmime::make_shared <testSocketFactory <greetingErrorSMTPTestSocket> >());
tr->setTimeoutHandlerFactory(vmime::make_shared <testTimeoutHandlerFactory>());
- VASSERT_THROW("Connection", tr->connect(),
- vmime::exceptions::connection_greeting_error);
+ VASSERT_THROW(
+ "Connection",
+ tr->connect(),
+ vmime::exceptions::connection_greeting_error
+ );
}
- void testMAILandRCPT()
- {
+ void testMAILandRCPT() {
+
vmime::shared_ptr <vmime::net::session> session = vmime::net::session::create();
- vmime::shared_ptr <vmime::net::transport> tr = session->getTransport
- (vmime::utility::url("smtp://localhost"));
+ vmime::shared_ptr <vmime::net::transport> tr =
+ session->getTransport(vmime::utility::url("smtp://localhost"));
tr->setSocketFactory(vmime::make_shared <testSocketFactory <MAILandRCPTSMTPTestSocket> >());
tr->setTimeoutHandlerFactory(vmime::make_shared <testTimeoutHandlerFactory>());
@@ -95,20 +96,22 @@ VMIME_TEST_SUITE_BEGIN(SMTPTransportTest)
tr->send(exp, recips, is, 0);
}
- void testChunking()
- {
+ void testChunking() {
+
vmime::shared_ptr <vmime::net::session> session = vmime::net::session::create();
- vmime::shared_ptr <vmime::net::transport> tr = session->getTransport
- (vmime::utility::url("smtp://localhost"));
+ vmime::shared_ptr <vmime::net::transport> tr =
+ session->getTransport(vmime::utility::url("smtp://localhost"));
tr->setSocketFactory(vmime::make_shared <testSocketFactory <chunkingSMTPTestSocket> >());
tr->setTimeoutHandlerFactory(vmime::make_shared <testTimeoutHandlerFactory>());
tr->connect();
- VASSERT("Test server should report it supports the CHUNKING extension!",
- vmime::dynamicCast <vmime::net::smtp::SMTPTransport>(tr)->getConnection()->hasExtension("CHUNKING"));
+ VASSERT(
+ "Test server should report it supports the CHUNKING extension!",
+ vmime::dynamicCast <vmime::net::smtp::SMTPTransport>(tr)->getConnection()->hasExtension("CHUNKING")
+ );
vmime::mailbox exp("[email protected]");
@@ -120,20 +123,22 @@ VMIME_TEST_SUITE_BEGIN(SMTPTransportTest)
tr->send(msg, exp, recips);
}
- void testSize_Chunking()
- {
+ void testSize_Chunking() {
+
vmime::shared_ptr <vmime::net::session> session = vmime::net::session::create();
- vmime::shared_ptr <vmime::net::transport> tr = session->getTransport
- (vmime::utility::url("smtp://localhost"));
+ vmime::shared_ptr <vmime::net::transport> tr =
+ session->getTransport(vmime::utility::url("smtp://localhost"));
tr->setSocketFactory(vmime::make_shared <testSocketFactory <bigMessageSMTPTestSocket <true> > >());
tr->setTimeoutHandlerFactory(vmime::make_shared <testTimeoutHandlerFactory>());
tr->connect();
- VASSERT("Test server should report it supports the SIZE extension!",
- vmime::dynamicCast <vmime::net::smtp::SMTPTransport>(tr)->getConnection()->hasExtension("SIZE"));
+ VASSERT(
+ "Test server should report it supports the SIZE extension!",
+ vmime::dynamicCast <vmime::net::smtp::SMTPTransport>(tr)->getConnection()->hasExtension("SIZE")
+ );
vmime::mailbox exp("[email protected]");
@@ -142,24 +147,29 @@ VMIME_TEST_SUITE_BEGIN(SMTPTransportTest)
vmime::shared_ptr <vmime::message> msg = vmime::make_shared <SMTPBigTestMessage4MB>();
- VASSERT_THROW("Connection", tr->send(msg, exp, recips),
- vmime::net::smtp::SMTPMessageSizeExceedsMaxLimitsException);
+ VASSERT_THROW(
+ "Max size limit exception",
+ tr->send(msg, exp, recips),
+ vmime::net::smtp::SMTPMessageSizeExceedsMaxLimitsException
+ );
}
- void testSize_NoChunking()
- {
+ void testSize_NoChunking() {
+
vmime::shared_ptr <vmime::net::session> session = vmime::net::session::create();
- vmime::shared_ptr <vmime::net::transport> tr = session->getTransport
- (vmime::utility::url("smtp://localhost"));
+ vmime::shared_ptr <vmime::net::transport> tr =
+ session->getTransport(vmime::utility::url("smtp://localhost"));
tr->setSocketFactory(vmime::make_shared <testSocketFactory <bigMessageSMTPTestSocket <false> > >());
tr->setTimeoutHandlerFactory(vmime::make_shared <testTimeoutHandlerFactory>());
tr->connect();
- VASSERT("Test server should report it supports the SIZE extension!",
- vmime::dynamicCast <vmime::net::smtp::SMTPTransport>(tr)->getConnection()->hasExtension("SIZE"));
+ VASSERT(
+ "Test server should report it supports the SIZE extension!",
+ vmime::dynamicCast <vmime::net::smtp::SMTPTransport>(tr)->getConnection()->hasExtension("SIZE")
+ );
vmime::mailbox exp("[email protected]");
@@ -168,18 +178,21 @@ VMIME_TEST_SUITE_BEGIN(SMTPTransportTest)
vmime::shared_ptr <vmime::message> msg = vmime::make_shared <SMTPBigTestMessage4MB>();
- VASSERT_THROW("Connection", tr->send(msg, exp, recips),
- vmime::net::smtp::SMTPMessageSizeExceedsMaxLimitsException);
+ VASSERT_THROW(
+ "Max size limit exception",
+ tr->send(msg, exp, recips),
+ vmime::net::smtp::SMTPMessageSizeExceedsMaxLimitsException
+ );
}
- void testSMTPUTF8_available()
- {
+ void testSMTPUTF8_available() {
+
// Test with UTF8 sender
{
vmime::shared_ptr <vmime::net::session> session = vmime::net::session::create();
- vmime::shared_ptr <vmime::net::transport> tr = session->getTransport
- (vmime::utility::url("smtp://localhost"));
+ vmime::shared_ptr <vmime::net::transport> tr =
+ session->getTransport(vmime::utility::url("smtp://localhost"));
tr->setSocketFactory(vmime::make_shared <testSocketFactory <UTF8SMTPTestSocket <true> > >());
tr->setTimeoutHandlerFactory(vmime::make_shared <testTimeoutHandlerFactory>());
@@ -213,8 +226,8 @@ VMIME_TEST_SUITE_BEGIN(SMTPTransportTest)
{
vmime::shared_ptr <vmime::net::session> session = vmime::net::session::create();
- vmime::shared_ptr <vmime::net::transport> tr = session->getTransport
- (vmime::utility::url("smtp://localhost"));
+ vmime::shared_ptr <vmime::net::transport> tr =
+ session->getTransport(vmime::utility::url("smtp://localhost"));
tr->setSocketFactory(vmime::make_shared <testSocketFactory <UTF8SMTPTestSocket <true> > >());
tr->setTimeoutHandlerFactory(vmime::make_shared <testTimeoutHandlerFactory>());
@@ -240,14 +253,14 @@ VMIME_TEST_SUITE_BEGIN(SMTPTransportTest)
}
}
- void testSMTPUTF8_notAvailable()
- {
+ void testSMTPUTF8_notAvailable() {
+
// Test with UTF8 sender
{
vmime::shared_ptr <vmime::net::session> session = vmime::net::session::create();
- vmime::shared_ptr <vmime::net::transport> tr = session->getTransport
- (vmime::utility::url("smtp://localhost"));
+ vmime::shared_ptr <vmime::net::transport> tr =
+ session->getTransport(vmime::utility::url("smtp://localhost"));
tr->setSocketFactory(vmime::make_shared <testSocketFactory <UTF8SMTPTestSocket <false> > >());
tr->setTimeoutHandlerFactory(vmime::make_shared <testTimeoutHandlerFactory>());
@@ -281,8 +294,8 @@ VMIME_TEST_SUITE_BEGIN(SMTPTransportTest)
{
vmime::shared_ptr <vmime::net::session> session = vmime::net::session::create();
- vmime::shared_ptr <vmime::net::transport> tr = session->getTransport
- (vmime::utility::url("smtp://localhost"));
+ vmime::shared_ptr <vmime::net::transport> tr =
+ session->getTransport(vmime::utility::url("smtp://localhost"));
tr->setSocketFactory(vmime::make_shared <testSocketFactory <UTF8SMTPTestSocket <false> > >());
tr->setTimeoutHandlerFactory(vmime::make_shared <testTimeoutHandlerFactory>());
@@ -309,4 +322,3 @@ VMIME_TEST_SUITE_BEGIN(SMTPTransportTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/net/smtp/SMTPTransportTestUtils.hpp b/tests/net/smtp/SMTPTransportTestUtils.hpp
index b5af2f10..8710639f 100644
--- a/tests/net/smtp/SMTPTransportTestUtils.hpp
+++ b/tests/net/smtp/SMTPTransportTestUtils.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
@@ -24,20 +24,21 @@
/** Accepts connection and fails on greeting.
*/
-class greetingErrorSMTPTestSocket : public lineBasedTestSocket
-{
+class greetingErrorSMTPTestSocket : public lineBasedTestSocket {
+
public:
- void onConnected()
- {
+ void onConnected() {
+
localSend("421 test.vmime.org Service not available, closing transmission channel\r\n");
disconnect();
}
- void processCommand()
- {
- if (!haveMoreLines())
+ void processCommand() {
+
+ if (!haveMoreLines()) {
return;
+ }
getNextLine();
@@ -52,12 +53,12 @@ public:
* Test send().
* Ensure MAIL and RCPT commands are sent correctly.
*/
-class MAILandRCPTSMTPTestSocket : public lineBasedTestSocket
-{
+class MAILandRCPTSMTPTestSocket : public lineBasedTestSocket {
+
public:
- MAILandRCPTSMTPTestSocket()
- {
+ MAILandRCPTSMTPTestSocket() {
+
m_recipients.insert("[email protected]");
m_recipients.insert("[email protected]");
m_recipients.insert("[email protected]");
@@ -66,60 +67,61 @@ public:
m_ehloSent = m_heloSent = m_mailSent = m_rcptSent = m_dataSent = m_quitSent = false;
}
- ~MAILandRCPTSMTPTestSocket()
- {
+ ~MAILandRCPTSMTPTestSocket() {
+
VASSERT("Client must send the DATA command", m_dataSent);
VASSERT("Client must send the QUIT command", m_quitSent);
}
- void onConnected()
- {
+ void onConnected() {
+
localSend("220 test.vmime.org Service ready\r\n");
processCommand();
m_state = STATE_COMMAND;
}
- void processCommand()
- {
- if (!haveMoreLines())
+ void processCommand() {
+
+ if (!haveMoreLines()) {
return;
+ }
vmime::string line = getNextLine();
std::istringstream iss(line);
- switch (m_state)
- {
+ switch (m_state) {
+
case STATE_NOT_CONNECTED:
localSend("451 Requested action aborted: invalid state\r\n");
break;
- case STATE_COMMAND:
- {
+ case STATE_COMMAND: {
+
std::string cmd;
iss >> cmd;
- if (cmd.empty())
- {
+ if (cmd.empty()) {
+
localSend("500 Syntax error, command unrecognized\r\n");
- }
- else if (cmd == "EHLO")
- {
+
+ } else if (cmd == "EHLO") {
+
localSend("502 Command not implemented\r\n");
m_ehloSent = true;
- }
- else if (cmd == "HELO")
- {
+
+ } else if (cmd == "HELO") {
+
VASSERT("Client must send the EHLO command before HELO", m_ehloSent);
localSend("250 OK\r\n");
m_heloSent = true;
- }
- else if (cmd == "MAIL")
- {
+
+ } else if (cmd == "MAIL") {
+
VASSERT("Client must send the HELO command", m_heloSent);
VASSERT("The MAIL command must be sent only one time", !m_mailSent);
@@ -128,9 +130,9 @@ public:
localSend("250 OK\r\n");
m_mailSent = true;
- }
- else if (cmd == "RCPT")
- {
+
+ } else if (cmd == "RCPT") {
+
const vmime::size_t lt = line.find('<');
const vmime::size_t gt = line.find('>');
@@ -138,23 +140,25 @@ public:
VASSERT("RCPT >", gt != vmime::string::npos);
VASSERT("RCPT ><", gt >= lt);
- const vmime::string recip = vmime::string
- (line.begin() + lt + 1, line.begin() + gt);
+ const vmime::string recip =
+ vmime::string(line.begin() + lt + 1, line.begin() + gt);
std::set <vmime::string>::iterator it =
m_recipients.find(recip);
- VASSERT(std::string("Recipient not found: '") + recip + "'",
- it != m_recipients.end());
+ VASSERT(
+ std::string("Recipient not found: '") + recip + "'",
+ it != m_recipients.end()
+ );
m_recipients.erase(it);
localSend("250 OK, recipient accepted\r\n");
m_rcptSent = true;
- }
- else if (cmd == "DATA")
- {
+
+ } else if (cmd == "DATA") {
+
VASSERT("Client must send the MAIL command", m_mailSent);
VASSERT("Client must send the RCPT command", m_rcptSent);
VASSERT("All recipients", m_recipients.empty());
@@ -165,35 +169,35 @@ public:
m_msgData.clear();
m_dataSent = true;
- }
- else if (cmd == "NOOP")
- {
+
+ } else if (cmd == "NOOP") {
+
localSend("250 Completed\r\n");
- }
- else if (cmd == "QUIT")
- {
+
+ } else if (cmd == "QUIT") {
+
m_quitSent = true;
localSend("221 test.vmime.org Service closing transmission channel\r\n");
- }
- else
- {
+
+ } else {
+
localSend("502 Command not implemented\r\n");
}
break;
}
- case STATE_DATA:
- {
- if (line == ".")
- {
+ case STATE_DATA: {
+
+ if (line == ".") {
+
VASSERT_EQ("Data", "Message data\r\n", m_msgData);
localSend("250 Message accepted for delivery\r\n");
m_state = STATE_COMMAND;
- }
- else
- {
+
+ } else {
+
m_msgData += line + "\r\n";
}
@@ -207,8 +211,7 @@ public:
private:
- enum State
- {
+ enum State {
STATE_NOT_CONNECTED,
STATE_COMMAND,
STATE_DATA
@@ -230,45 +233,45 @@ private:
*
* Test CHUNKING extension/BDAT command.
*/
-class chunkingSMTPTestSocket : public testSocket
-{
+class chunkingSMTPTestSocket : public testSocket {
+
public:
- chunkingSMTPTestSocket()
- {
+ chunkingSMTPTestSocket() {
+
m_state = STATE_NOT_CONNECTED;
m_bdatChunkCount = 0;
m_ehloSent = m_mailSent = m_rcptSent = m_quitSent = false;
}
- ~chunkingSMTPTestSocket()
- {
+ ~chunkingSMTPTestSocket() {
+
VASSERT_EQ("BDAT chunk count", 3, m_bdatChunkCount);
VASSERT("Client must send the QUIT command", m_quitSent);
}
- void onConnected()
- {
+ void onConnected() {
+
localSend("220 test.vmime.org Service ready\r\n");
processCommand();
m_state = STATE_COMMAND;
}
- void onDataReceived()
- {
- if (m_state == STATE_DATA)
- {
- if (m_bdatChunkReceived != m_bdatChunkSize)
- {
+ void onDataReceived() {
+
+ if (m_state == STATE_DATA) {
+
+ if (m_bdatChunkReceived != m_bdatChunkSize) {
+
const size_t remaining = m_bdatChunkSize - m_bdatChunkReceived;
const size_t received = localReceiveRaw(NULL, remaining);
m_bdatChunkReceived += received;
}
- if (m_bdatChunkReceived == m_bdatChunkSize)
- {
+ if (m_bdatChunkReceived == m_bdatChunkSize) {
+
m_state = STATE_COMMAND;
}
}
@@ -276,58 +279,59 @@ public:
processCommand();
}
- void processCommand()
- {
+ void processCommand() {
+
vmime::string line;
- if (!localReceiveLine(line))
+ if (!localReceiveLine(line)) {
return;
+ }
std::istringstream iss(line);
- switch (m_state)
- {
+ switch (m_state) {
+
case STATE_NOT_CONNECTED:
localSend("451 Requested action aborted: invalid state\r\n");
break;
- case STATE_COMMAND:
- {
+ case STATE_COMMAND: {
+
std::string cmd;
iss >> cmd;
- if (cmd == "EHLO")
- {
+ if (cmd == "EHLO") {
+
localSend("250-test.vmime.org says hello\r\n");
localSend("250 CHUNKING\r\n");
m_ehloSent = true;
- }
- else if (cmd == "HELO")
- {
+
+ } else if (cmd == "HELO") {
+
VASSERT("Client must not send the HELO command, as EHLO succeeded", false);
- }
- else if (cmd == "MAIL")
- {
+
+ } else if (cmd == "MAIL") {
+
VASSERT("The MAIL command must be sent only one time", !m_mailSent);
localSend("250 OK\r\n");
m_mailSent = true;
- }
- else if (cmd == "RCPT")
- {
+
+ } else if (cmd == "RCPT") {
+
localSend("250 OK, recipient accepted\r\n");
m_rcptSent = true;
- }
- else if (cmd == "DATA")
- {
+
+ } else if (cmd == "DATA") {
+
VASSERT("BDAT must be used here!", false);
- }
- else if (cmd == "BDAT")
- {
+
+ } else if (cmd == "BDAT") {
+
VASSERT("Client must send the MAIL command", m_mailSent);
VASSERT("Client must send the RCPT command", m_rcptSent);
@@ -337,23 +341,23 @@ public:
std::string last;
iss >> last;
- if (m_bdatChunkCount == 0)
- {
+ if (m_bdatChunkCount == 0) {
+
VASSERT_EQ("BDAT chunk1 size", 262144, chunkSize);
VASSERT_EQ("BDAT chunk1 last", "", last);
- }
- else if (m_bdatChunkCount == 1)
- {
+
+ } else if (m_bdatChunkCount == 1) {
+
VASSERT_EQ("BDAT chunk2 size", 262144, chunkSize);
VASSERT_EQ("BDAT chunk2 last", "", last);
- }
- else if (m_bdatChunkCount == 2)
- {
+
+ } else if (m_bdatChunkCount == 2) {
+
VASSERT_EQ("BDAT chunk3 size", 4712, chunkSize);
VASSERT_EQ("BDAT chunk3 last", "LAST", last);
- }
- else
- {
+
+ } else {
+
VASSERT("No more BDAT command should be issued!", false);
}
@@ -363,19 +367,19 @@ public:
m_state = STATE_DATA;
localSend("250 chunk received\r\n");
- }
- else if (cmd == "NOOP")
- {
+
+ } else if (cmd == "NOOP") {
+
localSend("250 Completed\r\n");
- }
- else if (cmd == "QUIT")
- {
+
+ } else if (cmd == "QUIT") {
+
localSend("221 test.vmime.org Service closing transmission channel\r\n");
m_quitSent = true;
- }
- else
- {
+
+ } else {
+
localSend("502 Command not implemented\r\n");
}
@@ -389,8 +393,7 @@ public:
private:
- enum State
- {
+ enum State {
STATE_NOT_CONNECTED,
STATE_COMMAND,
STATE_DATA
@@ -404,22 +407,21 @@ private:
};
-class SMTPTestMessage : public vmime::message
-{
+class SMTPTestMessage : public vmime::message {
+
public:
- vmime::size_t getChunkBufferSize() const
- {
+ vmime::size_t getChunkBufferSize() const {
+
static vmime::net::smtp::SMTPChunkingOutputStreamAdapter chunkStream(vmime::null, 0, NULL);
return chunkStream.getBlockSize();
}
- const std::vector <vmime::string>& getChunks() const
- {
+ const std::vector <vmime::string>& getChunks() const {
+
static std::vector <vmime::string> chunks;
- if (chunks.size() == 0)
- {
+ if (chunks.size() == 0) {
chunks.push_back(vmime::string(1000, 'A'));
chunks.push_back(vmime::string(3000, 'B'));
chunks.push_back(vmime::string(500000, 'C'));
@@ -429,12 +431,15 @@ public:
return chunks;
}
- void generateImpl
- (const vmime::generationContext& /* ctx */, vmime::utility::outputStream& outputStream,
- const size_t /* curLinePos */ = 0, size_t* /* newLinePos */ = NULL) const
- {
- for (size_t i = 0, n = getChunks().size() ; i < n ; ++i)
- {
+ void generateImpl(
+ const vmime::generationContext& /* ctx */,
+ vmime::utility::outputStream& outputStream,
+ const size_t /* curLinePos */ = 0,
+ size_t* /* newLinePos */ = NULL
+ ) const {
+
+ for (size_t i = 0, n = getChunks().size() ; i < n ; ++i) {
+
const vmime::string& chunk = getChunks()[i];
outputStream.write(chunk.data(), chunk.size());
}
@@ -448,72 +453,74 @@ public:
* Test SIZE extension.
*/
template <bool WITH_CHUNKING>
-class bigMessageSMTPTestSocket : public testSocket
-{
+class bigMessageSMTPTestSocket : public testSocket {
+
public:
- bigMessageSMTPTestSocket()
- {
+ bigMessageSMTPTestSocket() {
+
m_state = STATE_NOT_CONNECTED;
m_ehloSent = m_mailSent = m_rcptSent = m_quitSent = false;
}
- ~bigMessageSMTPTestSocket()
- {
+ ~bigMessageSMTPTestSocket() {
+
VASSERT("Client must send the QUIT command", m_quitSent);
}
- void onConnected()
- {
+ void onConnected() {
+
localSend("220 test.vmime.org Service ready\r\n");
processCommand();
m_state = STATE_COMMAND;
}
- void onDataReceived()
- {
+ void onDataReceived() {
+
processCommand();
}
- void processCommand()
- {
+ void processCommand() {
+
vmime::string line;
- if (!localReceiveLine(line))
+ if (!localReceiveLine(line)) {
return;
+ }
std::istringstream iss(line);
- switch (m_state)
- {
+ switch (m_state) {
+
case STATE_NOT_CONNECTED:
localSend("451 Requested action aborted: invalid state\r\n");
break;
- case STATE_COMMAND:
- {
+ case STATE_COMMAND: {
+
std::string cmd;
iss >> cmd;
- if (cmd == "EHLO")
- {
+ if (cmd == "EHLO") {
+
localSend("250-test.vmime.org says hello\r\n");
- if (WITH_CHUNKING)
+ if (WITH_CHUNKING) {
localSend("250-CHUNKING\r\n");
+ }
localSend("250 SIZE 1000000\r\n");
m_ehloSent = true;
- }
- else if (cmd == "HELO")
- {
+
+ } else if (cmd == "HELO") {
+
VASSERT("Client must not send the HELO command, as EHLO succeeded", false);
- }
- else if (cmd == "MAIL")
- {
+
+ } else if (cmd == "MAIL") {
+
VASSERT("The MAIL command must be sent only one time", !m_mailSent);
std::string address;
@@ -529,19 +536,19 @@ public:
localSend("552 Channel size limit exceeded\r\n");
m_mailSent = true;
- }
- else if (cmd == "NOOP")
- {
+
+ } else if (cmd == "NOOP") {
+
localSend("250 Completed\r\n");
- }
- else if (cmd == "QUIT")
- {
+
+ } else if (cmd == "QUIT") {
+
localSend("221 test.vmime.org Service closing transmission channel\r\n");
m_quitSent = true;
- }
- else
- {
+
+ } else {
+
VASSERT("No other command should be sent", false);
localSend("502 Command not implemented\r\n");
@@ -557,8 +564,7 @@ public:
private:
- enum State
- {
+ enum State {
STATE_NOT_CONNECTED,
STATE_COMMAND,
STATE_DATA
@@ -571,22 +577,25 @@ private:
template <unsigned long SIZE>
-class SMTPBigTestMessage : public vmime::message
-{
+class SMTPBigTestMessage : public vmime::message {
+
public:
- size_t getGeneratedSize(const vmime::generationContext& /* ctx */)
- {
+ size_t getGeneratedSize(const vmime::generationContext& /* ctx */) {
+
return SIZE;
}
- void generateImpl(const vmime::generationContext& /* ctx */,
- vmime::utility::outputStream& outputStream,
- const vmime::size_t /* curLinePos */ = 0,
- vmime::size_t* /* newLinePos */ = NULL) const
- {
- for (unsigned int i = 0, n = SIZE ; i < n ; ++i)
+ void generateImpl(
+ const vmime::generationContext& /* ctx */,
+ vmime::utility::outputStream& outputStream,
+ const vmime::size_t /* curLinePos */ = 0,
+ vmime::size_t* /* newLinePos */ = NULL
+ ) const {
+
+ for (unsigned int i = 0, n = SIZE ; i < n ; ++i) {
outputStream.write("X", 1);
+ }
}
};
@@ -597,20 +606,20 @@ typedef SMTPBigTestMessage <4194304> SMTPBigTestMessage4MB;
/** SMTP test server for SMTPUTF8 extension.
*/
template <bool SUPPORTS_UTF8>
-class UTF8SMTPTestSocket : public lineBasedTestSocket
-{
+class UTF8SMTPTestSocket : public lineBasedTestSocket {
+
public:
- UTF8SMTPTestSocket()
- {
- if (SUPPORTS_UTF8)
- {
+ UTF8SMTPTestSocket() {
+
+ if (SUPPORTS_UTF8) {
+
m_rcptLines.insert("RCPT TO:<[email protected]>");
m_rcptLines.insert("RCPT TO:<[email protected]>");
m_rcptLines.insert("RCPT TO:<ré[email protected]>");
- }
- else
- {
+
+ } else {
+
m_rcptLines.insert("RCPT TO:<[email protected]>");
m_rcptLines.insert("RCPT TO:<[email protected]>");
m_rcptLines.insert("RCPT TO:<[email protected]>");
@@ -620,75 +629,76 @@ public:
m_ehloSent = m_mailSent = m_rcptSent = m_dataSent = m_quitSent = false;
}
- ~UTF8SMTPTestSocket()
- {
+ ~UTF8SMTPTestSocket() {
+
}
- void onConnected()
- {
+ void onConnected() {
+
localSend("220 test.vmime.org Service ready\r\n");
processCommand();
m_state = STATE_COMMAND;
}
- void processCommand()
- {
- if (!haveMoreLines())
+ void processCommand() {
+
+ if (!haveMoreLines()) {
return;
+ }
vmime::string line = getNextLine();
std::istringstream iss(line);
- switch (m_state)
- {
+ switch (m_state) {
+
case STATE_NOT_CONNECTED:
localSend("451 Requested action aborted: invalid state\r\n");
break;
- case STATE_COMMAND:
- {
+ case STATE_COMMAND: {
+
std::string cmd;
iss >> cmd;
- if (cmd.empty())
- {
+ if (cmd.empty()) {
+
localSend("500 Syntax error, command unrecognized\r\n");
- }
- else if (cmd == "EHLO")
- {
- if (SUPPORTS_UTF8)
- {
+
+ } else if (cmd == "EHLO") {
+
+ if (SUPPORTS_UTF8) {
+
localSend("250-test.vmime.org\r\n");
localSend("250 SMTPUTF8\r\n");
- }
- else
- {
+
+ } else {
+
localSend("250 test.vmime.org\r\n");
}
m_ehloSent = true;
- }
- else if (cmd == "HELO")
- {
+
+ } else if (cmd == "HELO") {
+
VASSERT("Client must not send the HELO command, as EHLO succeeded", false);
- }
- else if (cmd == "MAIL")
- {
+
+ } else if (cmd == "MAIL") {
+
VASSERT("Client must send the EHLO command", m_ehloSent);
VASSERT("The MAIL command must be sent only one time", !m_mailSent);
- if (SUPPORTS_UTF8)
- {
+ if (SUPPORTS_UTF8) {
+
VASSERT(
"MAIL",
std::string("MAIL FROM:<[email protected]> SMTPUTF8") == line
|| std::string("MAIL FROM:<expé[email protected]> SMTPUTF8") == line
);
- }
- else
- {
+
+ } else {
+
VASSERT(
"MAIL",
std::string("MAIL FROM:<[email protected]>") == line
@@ -699,9 +709,9 @@ public:
localSend("250 OK\r\n");
m_mailSent = true;
- }
- else if (cmd == "RCPT")
- {
+
+ } else if (cmd == "RCPT") {
+
std::set <vmime::string>::iterator it = m_rcptLines.find(line);
VASSERT(std::string("RCPT not found: '") + line + "'", it != m_rcptLines.end());
@@ -711,9 +721,9 @@ public:
localSend("250 OK, recipient accepted\r\n");
m_rcptSent = true;
- }
- else if (cmd == "DATA")
- {
+
+ } else if (cmd == "DATA") {
+
VASSERT("Client must send the MAIL command", m_mailSent);
VASSERT("Client must send the RCPT command", m_rcptSent);
VASSERT("All recipients", m_rcptLines.empty());
@@ -724,35 +734,35 @@ public:
m_msgData.clear();
m_dataSent = true;
- }
- else if (cmd == "NOOP")
- {
+
+ } else if (cmd == "NOOP") {
+
localSend("250 Completed\r\n");
- }
- else if (cmd == "QUIT")
- {
+
+ } else if (cmd == "QUIT") {
+
m_quitSent = true;
localSend("221 test.vmime.org Service closing transmission channel\r\n");
- }
- else
- {
+
+ } else {
+
localSend("502 Command not implemented\r\n");
}
break;
}
- case STATE_DATA:
- {
- if (line == ".")
- {
+ case STATE_DATA: {
+
+ if (line == ".") {
+
VASSERT_EQ("Data", "Message data\r\n", m_msgData);
localSend("250 Message accepted for delivery\r\n");
m_state = STATE_COMMAND;
- }
- else
- {
+
+ } else {
+
m_msgData += line + "\r\n";
}
@@ -766,8 +776,7 @@ public:
private:
- enum State
- {
+ enum State {
STATE_NOT_CONNECTED,
STATE_COMMAND,
STATE_DATA
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());
-
- 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 testGenerateASCII() {
+
+ 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()
- {
- // From RFC-2047
- VASSERT_EQ("1", "[text: [[word: charset=US-ASCII, buffer=Keith Moore]]]",
- parseText("=?US-ASCII?Q?Keith_Moore?="));
+ void testParse() {
- 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("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==?="));
+ // From RFC-2047
+ 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(
+ "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==?="
+ )
+ );
// 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(
+ "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());
+ 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_TRUE("non-ascii", vmime::wordEncoder::isEncodingNeeded
- (ctx, "Buffer with some UTF-8 '\xc3\xa0'", 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"), ""
+ )
+ );
}
- 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(
+ "rfc2047",
+ vmime::wordEncoder::isEncodingNeeded(
+ vmime::generationContext::getDefaultContext(),
+ "foo bar =? 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"),
+ ""
+ )
+ );
+ }
- VASSERT_TRUE("new line 1", vmime::wordEncoder::isEncodingNeeded
- (vmime::generationContext::getDefaultContext(),
- "foo bar \n foo bar", vmime::charset("us-ascii"), ""));
+ void testGuessBestEncoding_QP() {
- VASSERT_TRUE("new line 2", vmime::wordEncoder::isEncodingNeeded
- (vmime::generationContext::getDefaultContext(),
- "foo bar \r foo bar", vmime::charset("us-ascii"), ""));
+ 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));
}
diff --git a/tests/security/digest/md5Test.cpp b/tests/security/digest/md5Test.cpp
index c7f0b521..ca6d3d45 100644
--- a/tests/security/digest/md5Test.cpp
+++ b/tests/security/digest/md5Test.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
@@ -54,8 +54,8 @@ VMIME_TEST_SUITE_BEGIN(md5Test)
// Test suites from RFC #1321
- void testRFC1321_1()
- {
+ void testRFC1321_1() {
+
INIT_DIGEST(algo, "md5");
algo->update("");
@@ -64,8 +64,8 @@ VMIME_TEST_SUITE_BEGIN(md5Test)
VASSERT_EQ("*", "d41d8cd98f00b204e9800998ecf8427e", algo->getHexDigest());
}
- void testRFC1321_2()
- {
+ void testRFC1321_2() {
+
INIT_DIGEST(algo, "md5");
algo->update("a");
@@ -74,8 +74,8 @@ VMIME_TEST_SUITE_BEGIN(md5Test)
VASSERT_EQ("*", "0cc175b9c0f1b6a831c399e269772661", algo->getHexDigest());
}
- void testRFC1321_3()
- {
+ void testRFC1321_3() {
+
INIT_DIGEST(algo, "md5");
algo->update("abc");
@@ -84,8 +84,8 @@ VMIME_TEST_SUITE_BEGIN(md5Test)
VASSERT_EQ("*", "900150983cd24fb0d6963f7d28e17f72", algo->getHexDigest());
}
- void testRFC1321_4()
- {
+ void testRFC1321_4() {
+
INIT_DIGEST(algo, "md5");
algo->update("message digest");
@@ -94,8 +94,8 @@ VMIME_TEST_SUITE_BEGIN(md5Test)
VASSERT_EQ("*", "f96b697d7cb7938d525a2f31aaf161d0", algo->getHexDigest());
}
- void testRFC1321_5()
- {
+ void testRFC1321_5() {
+
INIT_DIGEST(algo, "md5");
algo->update("abcdefghijklmnopqrstuvwxyz");
@@ -104,8 +104,8 @@ VMIME_TEST_SUITE_BEGIN(md5Test)
VASSERT_EQ("*", "c3fcd3d76192e4007dfb496cca67e13b", algo->getHexDigest());
}
- void testRFC1321_6()
- {
+ void testRFC1321_6() {
+
INIT_DIGEST(algo, "md5");
algo->update("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
@@ -114,8 +114,8 @@ VMIME_TEST_SUITE_BEGIN(md5Test)
VASSERT_EQ("*", "d174ab98d277d9f5a5611c2c9f419d9f", algo->getHexDigest());
}
- void testRFC1321_7()
- {
+ void testRFC1321_7() {
+
INIT_DIGEST(algo, "md5");
algo->update("12345678901234567890123456789012345678901234567890123456789012345678901234567890");
@@ -124,8 +124,8 @@ VMIME_TEST_SUITE_BEGIN(md5Test)
VASSERT_EQ("*", "57edf4a22be3c955ac49da2e2107b67a", algo->getHexDigest());
}
- void testReset()
- {
+ void testReset() {
+
INIT_DIGEST(algo, "md5");
algo->update("foo");
@@ -138,8 +138,8 @@ VMIME_TEST_SUITE_BEGIN(md5Test)
VASSERT_EQ("*", "d41d8cd98f00b204e9800998ecf8427e", algo->getHexDigest()); // empty string
}
- void testUpdate1()
- {
+ void testUpdate1() {
+
INIT_DIGEST(algo, "md5");
algo->update("");
@@ -148,8 +148,8 @@ VMIME_TEST_SUITE_BEGIN(md5Test)
VASSERT_EQ("*", "d41d8cd98f00b204e9800998ecf8427e", algo->getHexDigest());
}
- void testUpdate2()
- {
+ void testUpdate2() {
+
INIT_DIGEST(algo, "md5");
algo->update("a");
@@ -159,8 +159,8 @@ VMIME_TEST_SUITE_BEGIN(md5Test)
VASSERT_EQ("2", "0cc175b9c0f1b6a831c399e269772661", algo->getHexDigest());
}
- void testUpdate3()
- {
+ void testUpdate3() {
+
INIT_DIGEST(algo, "md5");
algo->update("ab");
@@ -170,8 +170,8 @@ VMIME_TEST_SUITE_BEGIN(md5Test)
VASSERT_EQ("3", "900150983cd24fb0d6963f7d28e17f72", algo->getHexDigest());
}
- void testUpdate4()
- {
+ void testUpdate4() {
+
INIT_DIGEST(algo, "md5");
algo->update("");
@@ -183,8 +183,8 @@ VMIME_TEST_SUITE_BEGIN(md5Test)
VASSERT_EQ("4", "f96b697d7cb7938d525a2f31aaf161d0", algo->getHexDigest());
}
- void testUpdate5()
- {
+ void testUpdate5() {
+
INIT_DIGEST(algo, "md5");
algo->update("abcd");
@@ -197,8 +197,8 @@ VMIME_TEST_SUITE_BEGIN(md5Test)
VASSERT_EQ("5", "c3fcd3d76192e4007dfb496cca67e13b", algo->getHexDigest());
}
- void testUpdate6()
- {
+ void testUpdate6() {
+
INIT_DIGEST(algo, "md5");
algo->update("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012");
@@ -211,8 +211,8 @@ VMIME_TEST_SUITE_BEGIN(md5Test)
VASSERT_EQ("6", "d174ab98d277d9f5a5611c2c9f419d9f", algo->getHexDigest());
}
- void testUpdate7()
- {
+ void testUpdate7() {
+
INIT_DIGEST(algo, "md5");
algo->update("12345678901234567890123456789");
@@ -226,4 +226,3 @@ VMIME_TEST_SUITE_BEGIN(md5Test)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/security/digest/sha1Test.cpp b/tests/security/digest/sha1Test.cpp
index c6ce1e65..cbcd1cf0 100644
--- a/tests/security/digest/sha1Test.cpp
+++ b/tests/security/digest/sha1Test.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
@@ -46,8 +46,8 @@ VMIME_TEST_SUITE_BEGIN(sha1Test)
// Test suites from FIPS PUB 180-1
// http://www.itl.nist.gov/fipspubs/fip180-1.htm
- void testFIPS180_1()
- {
+ void testFIPS180_1() {
+
INIT_DIGEST(algo, "sha1");
algo->update("abc");
@@ -56,8 +56,8 @@ VMIME_TEST_SUITE_BEGIN(sha1Test)
VASSERT_EQ("*", "a9993e364706816aba3e25717850c26c9cd0d89d", algo->getHexDigest());
}
- void testFIPS180_2()
- {
+ void testFIPS180_2() {
+
INIT_DIGEST(algo, "sha1");
algo->update("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq");
@@ -66,14 +66,15 @@ VMIME_TEST_SUITE_BEGIN(sha1Test)
VASSERT_EQ("*", "84983e441c3bd26ebaae4aa1f95129e5e54670f1", algo->getHexDigest());
}
- void testFIPS180_3()
- {
+ void testFIPS180_3() {
+
INIT_DIGEST(algo, "sha1");
vmime::byte_t* buffer = new vmime::byte_t[1000000];
- for (int i = 0 ; i < 1000000 ; ++i)
+ for (int i = 0 ; i < 1000000 ; ++i) {
buffer[i] = 'a';
+ }
algo->update(buffer, 1000000);
algo->finalize();
@@ -83,8 +84,8 @@ VMIME_TEST_SUITE_BEGIN(sha1Test)
VASSERT_EQ("*", "34aa973cd4c4daa4f61eeb2bdbad27316534016f", algo->getHexDigest());
}
- void testReset()
- {
+ void testReset() {
+
INIT_DIGEST(algo, "sha1");
algo->update("ab");
@@ -97,8 +98,8 @@ VMIME_TEST_SUITE_BEGIN(sha1Test)
VASSERT_EQ("*", "da39a3ee5e6b4b0d3255bfef95601890afd80709", algo->getHexDigest()); // empty string
}
- void testUpdate()
- {
+ void testUpdate() {
+
INIT_DIGEST(algo, "sha1");
algo->update("a");
@@ -116,4 +117,3 @@ VMIME_TEST_SUITE_BEGIN(sha1Test)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/testRunner.cpp b/tests/testRunner.cpp
index 08a06930..f1f13b25 100644
--- a/tests/testRunner.cpp
+++ b/tests/testRunner.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,19 +45,19 @@
#include "vmime/platforms/posix/posixHandler.hpp"
-class Clock
-{
+class Clock {
+
public:
- void reset()
- {
+ void reset() {
+
struct timezone tz;
gettimeofday(&m_start, &tz);
}
- double getDuration() const
- {
+ double getDuration() const {
+
struct timeval tv;
struct timezone tz;
@@ -73,18 +73,19 @@ private:
};
-class XmlTestListener : public CppUnit::TestListener
-{
+class XmlTestListener : public CppUnit::TestListener {
+
public:
XmlTestListener()
- : m_doc("utf-8"), m_testElt(NULL)
- {
+ : m_doc("utf-8"),
+ m_testElt(NULL) {
+
m_doc.setRootElement(new CppUnit::XmlElement("TestRun"));
}
- void startTest(CppUnit::Test* test)
- {
+ void startTest(CppUnit::Test* test) {
+
m_testElt = new CppUnit::XmlElement("Test");
m_suiteElt.back()->addElement(m_testElt);
@@ -93,16 +94,17 @@ public:
m_chrono.reset();
}
- void addFailure(const CppUnit::TestFailure& failure)
- {
+ void addFailure(const CppUnit::TestFailure& failure) {
+
CppUnit::XmlElement* failElt = new CppUnit::XmlElement("Failure");
m_testElt->addElement(failElt);
- failElt->addElement(new CppUnit::XmlElement("FailureType",
- failure.isError() ? "Error" : "Assertion"));
+ failElt->addElement(
+ new CppUnit::XmlElement("FailureType", failure.isError() ? "Error" : "Assertion")
+ );
+
+ if (failure.sourceLine().isValid()) {
- if (failure.sourceLine().isValid())
- {
CppUnit::XmlElement* locElt = new CppUnit::XmlElement("Location");
failElt->addElement(locElt);
@@ -116,8 +118,8 @@ public:
exElt->addElement(new CppUnit::XmlElement("Message", failure.thrownException()->what()));
}
- void endTest(CppUnit::Test* /* test */)
- {
+ void endTest(CppUnit::Test* /* test */) {
+
std::ostringstream ossTime;
ossTime << (m_chrono.getDuration() * 1000.0);
@@ -126,39 +128,42 @@ public:
m_testElt = NULL;
}
- void startSuite(CppUnit::Test* suite)
- {
- if (suite->getName() == "All Tests")
+ void startSuite(CppUnit::Test* suite) {
+
+ if (suite->getName() == "All Tests") {
return;
+ }
CppUnit::XmlElement* suiteElt = new CppUnit::XmlElement("Suite");
- if (m_suiteElt.size() == 0)
+ if (m_suiteElt.size() == 0) {
m_doc.rootElement().addElement(suiteElt);
- else
+ } else {
m_suiteElt.back()->addElement(suiteElt);
+ }
m_suiteElt.push_back(suiteElt);
suiteElt->addElement(new CppUnit::XmlElement("Name", suite->getName()));
}
- void endSuite(CppUnit::Test* /* suite */)
- {
- if (m_suiteElt.size())
+ void endSuite(CppUnit::Test* /* suite */) {
+
+ if (m_suiteElt.size()) {
m_suiteElt.pop_back();
+ }
}
- void startTestRun(CppUnit::Test* /* test */, CppUnit::TestResult* /* eventManager */)
- {
+ void startTestRun(CppUnit::Test* /* test */, CppUnit::TestResult* /* eventManager */) {
+
}
- void endTestRun(CppUnit::Test* /* test */, CppUnit::TestResult* /* eventManager */)
- {
+ void endTestRun(CppUnit::Test* /* test */, CppUnit::TestResult* /* eventManager */) {
+
}
- void output(std::ostream& os)
- {
+ void output(std::ostream& os) {
+
os << m_doc.toString();
}
@@ -175,43 +180,46 @@ private:
// see testUtils.hpp
-std::vector <std::string>& getTestModules()
-{
+std::vector <std::string>& getTestModules() {
+
static std::vector <std::string> allModules;
return allModules;
}
-void registerTestModule(const char* name_)
-{
+void registerTestModule(const char* name_) {
+
std::vector <std::string>& testModules = getTestModules();
std::string name(name_);
- if (std::find(testModules.begin(), testModules.end(), name) == testModules.end())
+ if (std::find(testModules.begin(), testModules.end(), name) == testModules.end()) {
testModules.push_back(name);
+ }
}
-const std::string getNormalizedPath(const std::string& path)
-{
+const std::string getNormalizedPath(const std::string& path) {
+
std::string res = path;
- for (std::size_t i = 0, n = res.length() ; i < n ; ++i)
- {
- if (res[i] == '\\')
+ for (std::size_t i = 0, n = res.length() ; i < n ; ++i) {
+
+ if (res[i] == '\\') {
res[i] = '/';
+ }
}
return res;
}
-const std::string getFileNameFromPath(const std::string& path)
-{
+const std::string getFileNameFromPath(const std::string& path) {
+
const std::size_t pos = path.find_last_of('/');
- if (pos == std::string::npos)
+ if (pos == std::string::npos) {
return "";
+ }
return path.substr(pos + 1);
}
@@ -220,8 +228,8 @@ const std::string getFileNameFromPath(const std::string& path)
static char g_moduleNameBuffer[2048];
-const char* getTestModuleNameFromSourceFile(const char *path_)
-{
+const char* getTestModuleNameFromSourceFile(const char *path_) {
+
static const std::string testRunnerPath(getNormalizedPath(__FILE__));
static const std::string testRunnerFileName(getFileNameFromPath(testRunnerPath));
@@ -244,29 +252,31 @@ const char* getTestModuleNameFromSourceFile(const char *path_)
}
-int main(int argc, char* argv[])
-{
+int main(int argc, char* argv[]) {
+
// Parse arguments
bool xmlOutput = false;
- for (int c = 1 ; c < argc ; ++c)
- {
+ for (int c = 1 ; c < argc ; ++c) {
+
const std::string arg = argv[c];
- if (arg == "--xml")
+ if (arg == "--xml") {
xmlOutput = true;
+ }
}
// Run the tests
- if (xmlOutput)
- {
+ if (xmlOutput) {
+
// Get the test suites from the registry and add them to the list of tests to run
CppUnit::TestRunner runner;
- for (unsigned int i = 0 ; i < getTestModules().size() ; ++i)
- {
- runner.addTest(CppUnit::TestFactoryRegistry::
- getRegistry(getTestModules()[i]).makeTest());
+ for (unsigned int i = 0 ; i < getTestModules().size() ; ++i) {
+
+ runner.addTest(
+ CppUnit::TestFactoryRegistry::getRegistry(getTestModules()[i]).makeTest()
+ );
}
XmlTestListener xmlListener;
@@ -283,9 +293,9 @@ int main(int argc, char* argv[])
// Return error code 1 if a test failed
return result.wasSuccessful() ? 0 : 1;
- }
- else
- {
+
+ } else {
+
// Get the top level suite from the registry
CppUnit::TextUi::TestRunner runner;
runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
@@ -293,4 +303,3 @@ int main(int argc, char* argv[])
return runner.run() ? 0 : 1;
}
}
-
diff --git a/tests/testUtils.cpp b/tests/testUtils.cpp
index 6e31d93f..ae755474 100644
--- a/tests/testUtils.cpp
+++ b/tests/testUtils.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
@@ -36,8 +36,8 @@
// testSocket
-void testSocket::connect(const vmime::string& address, const vmime::port_t port)
-{
+void testSocket::connect(const vmime::string& address, const vmime::port_t port) {
+
m_address = address;
m_port = port;
m_connected = true;
@@ -46,96 +46,96 @@ void testSocket::connect(const vmime::string& address, const vmime::port_t port)
}
-void testSocket::disconnect()
-{
+void testSocket::disconnect() {
+
m_address.clear();
m_port = 0;
m_connected = false;
}
-bool testSocket::isConnected() const
-{
+bool testSocket::isConnected() const {
+
return m_connected;
}
-vmime::size_t testSocket::getBlockSize() const
-{
+vmime::size_t testSocket::getBlockSize() const {
+
return 16384;
}
-unsigned int testSocket::getStatus() const
-{
+unsigned int testSocket::getStatus() const {
+
return 0;
}
-const vmime::string testSocket::getPeerName() const
-{
+const vmime::string testSocket::getPeerName() const {
+
return "test.vmime.org";
}
-const vmime::string testSocket::getPeerAddress() const
-{
+const vmime::string testSocket::getPeerAddress() const {
+
return "127.0.0.1";
}
-vmime::shared_ptr <vmime::net::timeoutHandler> testSocket::getTimeoutHandler()
-{
+vmime::shared_ptr <vmime::net::timeoutHandler> testSocket::getTimeoutHandler() {
+
return vmime::null;
}
-void testSocket::setTracer(const vmime::shared_ptr <vmime::net::tracer>& /* tracer */)
-{
+void testSocket::setTracer(const vmime::shared_ptr <vmime::net::tracer>& /* tracer */) {
+
}
-vmime::shared_ptr <vmime::net::tracer> testSocket::getTracer()
-{
+vmime::shared_ptr <vmime::net::tracer> testSocket::getTracer() {
+
return vmime::null;
}
-bool testSocket::waitForRead(const int /* msecs */)
-{
+bool testSocket::waitForRead(const int /* msecs */) {
+
return true;
}
-bool testSocket::waitForWrite(const int /* msecs */)
-{
+bool testSocket::waitForWrite(const int /* msecs */) {
+
return true;
}
-void testSocket::receive(vmime::string& buffer)
-{
+void testSocket::receive(vmime::string& buffer) {
+
buffer = m_inBuffer;
m_inBuffer.clear();
}
-void testSocket::send(const vmime::string& buffer)
-{
+void testSocket::send(const vmime::string& buffer) {
+
m_outBuffer += buffer;
onDataReceived();
}
-void testSocket::send(const char* str)
-{
+void testSocket::send(const char* str) {
+
sendRaw(reinterpret_cast <const vmime::byte_t*>(str), strlen(str));
}
-vmime::size_t testSocket::receiveRaw(vmime::byte_t* buffer, const size_t count)
-{
+vmime::size_t testSocket::receiveRaw(vmime::byte_t* buffer, const size_t count) {
+
const size_t n = std::min(count, static_cast <size_t>(m_inBuffer.size()));
std::copy(m_inBuffer.begin(), m_inBuffer.begin() + n, buffer);
@@ -145,21 +145,21 @@ vmime::size_t testSocket::receiveRaw(vmime::byte_t* buffer, const size_t count)
}
-void testSocket::sendRaw(const vmime::byte_t* buffer, const size_t count)
-{
+void testSocket::sendRaw(const vmime::byte_t* buffer, const size_t count) {
+
send(vmime::utility::stringUtils::makeStringFromBytes(buffer, count));
}
-vmime::size_t testSocket::sendRawNonBlocking(const vmime::byte_t* buffer, const size_t count)
-{
+vmime::size_t testSocket::sendRawNonBlocking(const vmime::byte_t* buffer, const size_t count) {
+
sendRaw(buffer, count);
return count;
}
-void testSocket::localSend(const vmime::string& buffer)
-{
+void testSocket::localSend(const vmime::string& buffer) {
+
m_inBuffer += buffer;
#if DEBUG_SOCKET_IN_OUT
@@ -169,23 +169,24 @@ void testSocket::localSend(const vmime::string& buffer)
}
-void testSocket::localReceive(vmime::string& buffer)
-{
+void testSocket::localReceive(vmime::string& buffer) {
+
buffer = m_outBuffer;
m_outBuffer.clear();
}
-bool testSocket::localReceiveLine(vmime::string& line)
-{
+bool testSocket::localReceiveLine(vmime::string& line) {
+
vmime::size_t eol;
- if ((eol = m_outBuffer.find('\n')) != vmime::string::npos)
- {
+ if ((eol = m_outBuffer.find('\n')) != vmime::string::npos) {
+
line = vmime::string(m_outBuffer.begin(), m_outBuffer.begin() + eol);
- if (!line.empty() && line[line.length() - 1] == '\r')
+ if (!line.empty() && line[line.length() - 1] == '\r') {
line.erase(line.end() - 1, line.end());
+ }
m_outBuffer.erase(m_outBuffer.begin(), m_outBuffer.begin() + eol + 1);
@@ -196,14 +197,15 @@ bool testSocket::localReceiveLine(vmime::string& line)
}
-vmime::size_t testSocket::localReceiveRaw(vmime::byte_t* buffer, const size_t count)
-{
+vmime::size_t testSocket::localReceiveRaw(vmime::byte_t* buffer, const size_t count) {
+
const size_t received = std::min(count, static_cast <size_t>(m_outBuffer.size()));
- if (received != 0)
- {
- if (buffer != NULL)
+ if (received != 0) {
+
+ if (buffer) {
std::copy(m_outBuffer.begin(), m_outBuffer.begin() + received, buffer);
+ }
m_outBuffer.erase(m_outBuffer.begin(), m_outBuffer.begin() + received);
}
@@ -212,22 +214,22 @@ vmime::size_t testSocket::localReceiveRaw(vmime::byte_t* buffer, const size_t co
}
-void testSocket::onDataReceived()
-{
+void testSocket::onDataReceived() {
+
// Override
}
-void testSocket::onConnected()
-{
+void testSocket::onConnected() {
+
// Override
}
// lineBasedTestSocket
-void lineBasedTestSocket::onDataReceived()
-{
+void lineBasedTestSocket::onDataReceived() {
+
vmime::string chunk;
localReceive(chunk);
@@ -235,12 +237,13 @@ void lineBasedTestSocket::onDataReceived()
vmime::size_t eol;
- while ((eol = m_buffer.find('\n')) != vmime::string::npos)
- {
+ while ((eol = m_buffer.find('\n')) != vmime::string::npos) {
+
vmime::string line(std::string(m_buffer.begin(), m_buffer.begin() + eol));
- if (!line.empty() && line[line.length() - 1] == '\r')
+ if (!line.empty() && line[line.length() - 1] == '\r') {
line.erase(line.end() - 1, line.end());
+ }
#if DEBUG_SOCKET_IN_OUT
std::cout << "< " << vmime::utility::stringUtils::trim(line) << std::endl;
@@ -250,20 +253,22 @@ void lineBasedTestSocket::onDataReceived()
m_buffer.erase(m_buffer.begin(), m_buffer.begin() + eol + 1);
}
- while (!m_lines.empty())
+ while (!m_lines.empty()) {
processCommand();
+ }
}
-const vmime::string lineBasedTestSocket::getNextLine()
-{
+const vmime::string lineBasedTestSocket::getNextLine() {
+
const vmime::string line = m_lines.front();
m_lines.erase(m_lines.begin(), m_lines.begin() + 1);
return line;
}
-bool lineBasedTestSocket::haveMoreLines() const
-{
+
+bool lineBasedTestSocket::haveMoreLines() const {
+
return !m_lines.empty();
}
@@ -271,47 +276,48 @@ bool lineBasedTestSocket::haveMoreLines() const
// testTimeoutHandler
testTimeoutHandler::testTimeoutHandler(const unsigned long delay)
- : m_delay(delay), m_start(0)
-{
+ : m_delay(delay),
+ m_start(0) {
+
}
-bool testTimeoutHandler::isTimeOut()
-{
+bool testTimeoutHandler::isTimeOut() {
+
return (vmime::platform::getHandler()->getUnixTime() - m_start) >= m_delay;
}
-void testTimeoutHandler::resetTimeOut()
-{
+void testTimeoutHandler::resetTimeOut() {
+
m_start = vmime::platform::getHandler()->getUnixTime();
}
-bool testTimeoutHandler::handleTimeOut()
-{
+bool testTimeoutHandler::handleTimeOut() {
+
return false;
}
// testTimeoutHandlerFactory : public vmime::net::timeoutHandlerFactory
-vmime::shared_ptr <vmime::net::timeoutHandler> testTimeoutHandlerFactory::create()
-{
+vmime::shared_ptr <vmime::net::timeoutHandler> testTimeoutHandlerFactory::create() {
+
return vmime::make_shared <testTimeoutHandler>();
}
// Exception helper
-std::ostream& operator<<(std::ostream& os, const vmime::exception& e)
-{
+std::ostream& operator<<(std::ostream& os, const vmime::exception& e) {
+
os << "* vmime::exceptions::" << e.name() << std::endl;
os << " what = " << e.what() << std::endl;
// More information for special exceptions
- if (dynamic_cast <const vmime::exceptions::command_error*>(&e))
- {
+ if (dynamic_cast <const vmime::exceptions::command_error*>(&e)) {
+
const vmime::exceptions::command_error& cee =
dynamic_cast <const vmime::exceptions::command_error&>(e);
@@ -319,32 +325,32 @@ std::ostream& operator<<(std::ostream& os, const vmime::exception& e)
os << " response = " << cee.response() << std::endl;
}
- if (dynamic_cast <const vmime::exceptions::invalid_response*>(&e))
- {
+ if (dynamic_cast <const vmime::exceptions::invalid_response*>(&e)) {
+
const vmime::exceptions::invalid_response& ir =
dynamic_cast <const vmime::exceptions::invalid_response&>(e);
os << " response = " << ir.response() << std::endl;
}
- if (dynamic_cast <const vmime::exceptions::connection_greeting_error*>(&e))
- {
+ if (dynamic_cast <const vmime::exceptions::connection_greeting_error*>(&e)) {
+
const vmime::exceptions::connection_greeting_error& cgee =
dynamic_cast <const vmime::exceptions::connection_greeting_error&>(e);
os << " response = " << cgee.response() << std::endl;
}
- if (dynamic_cast <const vmime::exceptions::authentication_error*>(&e))
- {
+ if (dynamic_cast <const vmime::exceptions::authentication_error*>(&e)) {
+
const vmime::exceptions::authentication_error& aee =
dynamic_cast <const vmime::exceptions::authentication_error&>(e);
os << " response = " << aee.response() << std::endl;
}
- if (dynamic_cast <const vmime::exceptions::filesystem_exception*>(&e))
- {
+ if (dynamic_cast <const vmime::exceptions::filesystem_exception*>(&e)) {
+
const vmime::exceptions::filesystem_exception& fse =
dynamic_cast <const vmime::exceptions::filesystem_exception&>(e);
@@ -352,29 +358,29 @@ std::ostream& operator<<(std::ostream& os, const vmime::exception& e)
getFileSystemFactory()->pathToString(fse.path()) << std::endl;
}
- if (e.other() != NULL)
+ if (e.other()) {
os << *e.other();
+ }
return os;
}
-const vmime::string toHex(const vmime::string str)
-{
+const vmime::string toHex(const vmime::string str) {
+
static const char hexChars[] = "0123456789abcdef";
vmime::string res = "\n";
- for (size_t i = 0 ; i < str.length() ; i += 16)
- {
- size_t r = std::min
- (static_cast <size_t>(16), str.length() - i);
+ for (size_t i = 0 ; i < str.length() ; i += 16) {
+
+ size_t r = std::min(static_cast <size_t>(16), str.length() - i);
vmime::string hex;
vmime::string chr;
- for (size_t j = 0 ; j < r ; ++j)
- {
+ for (size_t j = 0 ; j < r ; ++j) {
+
const unsigned char c = str[i + j];
hex += hexChars[c / 16];
@@ -387,8 +393,9 @@ const vmime::string toHex(const vmime::string str)
chr += '.';
}
- for (size_t j = r ; j < 16 ; ++j)
+ for (size_t j = r ; j < 16 ; ++j) {
hex += " ";
+ }
res += hex + " " + chr + "\n";
}
diff --git a/tests/testUtils.hpp b/tests/testUtils.hpp
index d17c38b2..e6bf1eee 100644
--- a/tests/testUtils.hpp
+++ b/tests/testUtils.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
@@ -88,123 +88,134 @@
#define VMIME_TEST(name) CPPUNIT_TEST(name);
-namespace CppUnit
-{
+namespace CppUnit {
+
// Work-around for comparing 'std::string' against 'char*'
- inline void assertEquals(const char* expected, const std::string actual,
- SourceLine sourceLine, const std::string &message)
- {
+ inline void assertEquals(
+ const char* expected,
+ const std::string actual,
+ SourceLine sourceLine,
+ const std::string &message
+ ) {
+
assertEquals(std::string(expected), actual, sourceLine, message);
}
template <typename X, typename Y>
- void assertEquals(const X expected, const Y actual,
- SourceLine sourceLine, const std::string &message)
- {
+ void assertEquals(
+ const X expected,
+ const Y actual,
+ SourceLine sourceLine,
+ const std::string &message
+ ) {
+
assertEquals(static_cast <Y>(expected), actual, sourceLine, message);
}
}
-namespace std
-{
+namespace std {
+
+inline std::ostream& operator<<(std::ostream& os, const vmime::charset& ch) {
-inline std::ostream& operator<<(std::ostream& os, const vmime::charset& ch)
-{
os << "[charset: " << ch.getName() << "]";
- return (os);
+ return os;
}
-inline std::ostream& operator<<(std::ostream& os, const vmime::word& w)
-{
+inline std::ostream& operator<<(std::ostream& os, const vmime::word& w) {
+
os << "[word: charset=" << w.getCharset().getName()
<< ", buffer=" << w.getBuffer();
- if (!w.getLanguage().empty())
+ if (!w.getLanguage().empty()) {
os << ", lang=" << w.getLanguage();
+ }
os << "]";
- return (os);
+ return os;
}
-inline std::ostream& operator<<(std::ostream& os, const vmime::text& txt)
-{
+inline std::ostream& operator<<(std::ostream& os, const vmime::text& txt) {
+
os << "[text: [";
- for (size_t i = 0 ; i < txt.getWordCount() ; ++i)
- {
+ for (size_t i = 0 ; i < txt.getWordCount() ; ++i) {
+
const vmime::word& w = *txt.getWordAt(i);
- if (i != 0)
+ if (i != 0) {
os << ",";
+ }
os << w;
}
os << "]]";
- return (os);
+ return os;
}
-inline std::ostream& operator<<(std::ostream& os, const vmime::emailAddress& email)
-{
+inline std::ostream& operator<<(std::ostream& os, const vmime::emailAddress& email) {
+
os << email.generate();
- return (os);
+ return os;
}
-inline std::ostream& operator<<(std::ostream& os, const vmime::mailbox& mbox)
-{
+inline std::ostream& operator<<(std::ostream& os, const vmime::mailbox& mbox) {
+
os << "[mailbox: name=" << mbox.getName() << ", email=" << mbox.getEmail() << "]";
- return (os);
+ return os;
}
-inline std::ostream& operator<<(std::ostream& os, const vmime::mailboxGroup& group)
-{
+inline std::ostream& operator<<(std::ostream& os, const vmime::mailboxGroup& group) {
+
os << "[mailbox-group: name=" << group.getName() << ", list=[";
- for (size_t i = 0 ; i < group.getMailboxCount() ; ++i)
- {
- if (i != 0)
+ for (size_t i = 0 ; i < group.getMailboxCount() ; ++i) {
+
+ if (i != 0) {
os << ",";
+ }
os << *group.getMailboxAt(i);
}
os << "]]";
- return (os);
+ return os;
}
-inline std::ostream& operator<<(std::ostream& os, const vmime::addressList& list)
-{
+inline std::ostream& operator<<(std::ostream& os, const vmime::addressList& list) {
+
os << "[address-list: [";
- for (size_t i = 0 ; i < list.getAddressCount() ; ++i)
- {
+ for (size_t i = 0 ; i < list.getAddressCount() ; ++i) {
+
const vmime::address& addr = *list.getAddressAt(i);
- if (i != 0)
+ if (i != 0) {
os << ",";
+ }
+
+ if (addr.isGroup()) {
- if (addr.isGroup())
- {
const vmime::mailboxGroup& group =
dynamic_cast <const vmime::mailboxGroup&>(addr);
os << group;
- }
- else
- {
+
+ } else {
+
const vmime::mailbox& mbox =
dynamic_cast <const vmime::mailbox&>(addr);
@@ -214,25 +225,25 @@ inline std::ostream& operator<<(std::ostream& os, const vmime::addressList& list
os << "]]";
- return (os);
+ return os;
}
-inline std::ostream& operator<<(std::ostream& os, const vmime::datetime& d)
-{
+inline std::ostream& operator<<(std::ostream& os, const vmime::datetime& d) {
+
os << "[datetime: " << d.getYear() << "/" << d.getMonth() << "/" << d.getDay();
os << " " << d.getHour() << ":" << d.getMinute() << ":" << d.getSecond();
os << " #" << d.getZone() << "]";
- return (os);
+ return os;
}
-inline std::ostream& operator<<(std::ostream& os, const vmime::encoding& enc)
-{
+inline std::ostream& operator<<(std::ostream& os, const vmime::encoding& enc) {
+
os << enc.generate();
- return (os);
+ return os;
}
@@ -246,8 +257,8 @@ inline std::ostream& operator<<(std::ostream& os, const vmime::encoding& enc)
// and send(). Server reads incoming data with localReceive() and sends data
// to client with localSend().
-class testSocket : public vmime::net::socket
-{
+class testSocket : public vmime::net::socket {
+
public:
void connect(const vmime::string& address, const vmime::port_t port);
@@ -327,24 +338,26 @@ private:
template <typename T>
-class testSocketFactory : public vmime::net::socketFactory
-{
+class testSocketFactory : public vmime::net::socketFactory {
+
public:
- vmime::shared_ptr <vmime::net::socket> create()
- {
+ vmime::shared_ptr <vmime::net::socket> create() {
+
return vmime::make_shared <T>();
}
- vmime::shared_ptr <vmime::net::socket> create(const vmime::shared_ptr <vmime::net::timeoutHandler>& /* th */)
- {
+ vmime::shared_ptr <vmime::net::socket> create(
+ const vmime::shared_ptr <vmime::net::timeoutHandler>& /* th */
+ ) {
+
return vmime::make_shared <T>();
}
};
-class lineBasedTestSocket : public testSocket
-{
+class lineBasedTestSocket : public testSocket {
+
public:
void onDataReceived();
@@ -361,8 +374,8 @@ private:
};
-class testTimeoutHandler : public vmime::net::timeoutHandler
-{
+class testTimeoutHandler : public vmime::net::timeoutHandler {
+
public:
testTimeoutHandler(const unsigned long delay = 3);
@@ -378,8 +391,8 @@ private:
};
-class testTimeoutHandlerFactory : public vmime::net::timeoutHandlerFactory
-{
+class testTimeoutHandlerFactory : public vmime::net::timeoutHandlerFactory {
+
public:
vmime::shared_ptr <vmime::net::timeoutHandler> create();
diff --git a/tests/utility/datetimeUtilsTest.cpp b/tests/utility/datetimeUtilsTest.cpp
index 1e21c5f9..77ce2425 100644
--- a/tests/utility/datetimeUtilsTest.cpp
+++ b/tests/utility/datetimeUtilsTest.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
@@ -43,8 +43,8 @@ VMIME_TEST_SUITE_BEGIN(datetimeUtilsTest)
typedef vmime::utility::datetimeUtils datetimeUtils;
- void testIsLeapYear()
- {
+ void testIsLeapYear() {
+
VASSERT_EQ("1", false, datetimeUtils::isLeapYear(1999));
VASSERT_EQ("2", false, datetimeUtils::isLeapYear(1800));
VASSERT_EQ("3", false, datetimeUtils::isLeapYear(1900));
@@ -55,8 +55,8 @@ VMIME_TEST_SUITE_BEGIN(datetimeUtilsTest)
VASSERT_EQ("7", true, datetimeUtils::isLeapYear(2000));
}
- void testGetDaysInMonth()
- {
+ void testGetDaysInMonth() {
+
VASSERT_EQ("1", 31, datetimeUtils::getDaysInMonth(2006, 1));
VASSERT_EQ("2", 28, datetimeUtils::getDaysInMonth(2006, 2));
VASSERT_EQ("3", 31, datetimeUtils::getDaysInMonth(2006, 3));
@@ -71,8 +71,8 @@ VMIME_TEST_SUITE_BEGIN(datetimeUtilsTest)
VASSERT_EQ("12", 31, datetimeUtils::getDaysInMonth(2006, 12));
}
- void testGetDaysInMonthLeapYear()
- {
+ void testGetDaysInMonthLeapYear() {
+
VASSERT_EQ("1", 31, datetimeUtils::getDaysInMonth(2004, 1));
VASSERT_EQ("2", 29, datetimeUtils::getDaysInMonth(2004, 2));
VASSERT_EQ("3", 31, datetimeUtils::getDaysInMonth(2004, 3));
@@ -87,13 +87,11 @@ VMIME_TEST_SUITE_BEGIN(datetimeUtilsTest)
VASSERT_EQ("12", 31, datetimeUtils::getDaysInMonth(2004, 12));
}
- void testToUniversalTime()
- {
- const vmime::datetime local
- (2005, 12, 2, 12, 34, 56, -789);
+ void testToUniversalTime() {
+
+ const vmime::datetime local(2005, 12, 2, 12, 34, 56, -789);
- const vmime::datetime gmt =
- datetimeUtils::toUniversalTime(local);
+ const vmime::datetime gmt = datetimeUtils::toUniversalTime(local);
// 789 is 13 hours, 9 minutes later
VASSERT_EQ("1", 2005, gmt.getYear());
@@ -105,13 +103,11 @@ VMIME_TEST_SUITE_BEGIN(datetimeUtilsTest)
VASSERT_EQ("7", 0, gmt.getZone());
}
- void testToLocalTime()
- {
- const vmime::datetime date
- (2005, 12, 2, 12, 34, 56, -120); // GMT-2
+ void testToLocalTime() {
- const vmime::datetime local =
- datetimeUtils::toLocalTime(date, 120); // GMT+2
+ const vmime::datetime date(2005, 12, 2, 12, 34, 56, -120); // GMT-2
+
+ const vmime::datetime local = datetimeUtils::toLocalTime(date, 120); // GMT+2
VASSERT_EQ("1", 2005, local.getYear());
VASSERT_EQ("2", 12, local.getMonth());
@@ -122,8 +118,8 @@ VMIME_TEST_SUITE_BEGIN(datetimeUtilsTest)
VASSERT_EQ("7", 120, local.getZone());
}
- void testGetDayOfWeek()
- {
+ void testGetDayOfWeek() {
+
VASSERT_EQ("1", vmime::datetime::WEDNESDAY, datetimeUtils::getDayOfWeek(1969, 12, 31));
VASSERT_EQ("2", vmime::datetime::FRIDAY, datetimeUtils::getDayOfWeek(1976, 4, 9));
VASSERT_EQ("3", vmime::datetime::TUESDAY, datetimeUtils::getDayOfWeek(1987, 6, 23));
@@ -135,8 +131,8 @@ VMIME_TEST_SUITE_BEGIN(datetimeUtilsTest)
VASSERT_EQ("9", vmime::datetime::FRIDAY, datetimeUtils::getDayOfWeek(2027, 3, 12));
}
- void testGetWeekOfYear()
- {
+ void testGetWeekOfYear() {
+
VASSERT_EQ("1.1", 52, datetimeUtils::getWeekOfYear(2003, 12, 27));
VASSERT_EQ("1.2", 52, datetimeUtils::getWeekOfYear(2003, 12, 28));
VASSERT_EQ("1.3", 1, datetimeUtils::getWeekOfYear(2003, 12, 29, true));
@@ -159,4 +155,3 @@ VMIME_TEST_SUITE_BEGIN(datetimeUtilsTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/utility/encoder/b64EncoderTest.cpp b/tests/utility/encoder/b64EncoderTest.cpp
index fa6fd766..36fa61ac 100644
--- a/tests/utility/encoder/b64EncoderTest.cpp
+++ b/tests/utility/encoder/b64EncoderTest.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,10 @@ VMIME_TEST_SUITE_BEGIN(b64EncoderTest)
VMIME_TEST_LIST_END
- void testBase64()
- {
- static const vmime::string testSuites[] =
- {
+ void testBase64() {
+
+ static const vmime::string testSuites[] = {
+
// Test 1
"",
@@ -96,8 +96,8 @@ VMIME_TEST_SUITE_BEGIN(b64EncoderTest)
};
- for (unsigned int i = 0 ; i < sizeof(testSuites) / sizeof(testSuites[0]) / 2 ; ++i)
- {
+ for (unsigned int i = 0 ; i < sizeof(testSuites) / sizeof(testSuites[0]) / 2 ; ++i) {
+
const vmime::string decoded = testSuites[i * 2];
const vmime::string encoded = testSuites[i * 2 + 1];
@@ -111,25 +111,36 @@ VMIME_TEST_SUITE_BEGIN(b64EncoderTest)
VASSERT_EQ(oss.str() + "decoding", decoded, decode("base64", encoded));
// Multiple and successive encoding/decoding
- VASSERT_EQ(oss.str() + "multiple1", decoded,
+ VASSERT_EQ(
+ oss.str() + "multiple1",
+ decoded,
decode("base64",
- encode("base64", decoded)));
+ encode("base64", decoded))
+ );
- VASSERT_EQ(oss.str() + "multiple2", decoded,
+ VASSERT_EQ(
+ oss.str() + "multiple2",
+ decoded,
decode("base64",
decode("base64",
encode("base64",
- encode("base64", decoded)))));
+ encode("base64", decoded))))
+ );
- VASSERT_EQ(oss.str() + "multiple3", decoded,
+ VASSERT_EQ(
+ oss.str() + "multiple3",
+ decoded,
decode("base64",
decode("base64",
decode("base64",
encode("base64",
encode("base64",
- encode("base64", decoded)))))));
+ encode("base64", decoded))))))
+ );
- VASSERT_EQ(oss.str() + "multiple4", decoded,
+ VASSERT_EQ(
+ oss.str() + "multiple4",
+ decoded,
decode("base64",
decode("base64",
decode("base64",
@@ -137,17 +148,21 @@ VMIME_TEST_SUITE_BEGIN(b64EncoderTest)
encode("base64",
encode("base64",
encode("base64",
- encode("base64", decoded)))))))));
+ encode("base64", decoded))))))))
+ );
- VASSERT(oss.str() + "encoded size",
+ VASSERT(
+ oss.str() + "encoded size",
getEncoder("base64")->getEncodedSize(decoded.length())
- >= encode("base64", decoded).length());
+ >= encode("base64", decoded).length()
+ );
- VASSERT(oss.str() + "decoded size",
+ VASSERT(
+ oss.str() + "decoded size",
getEncoder("base64")->getDecodedSize(encoded.length())
- >= decode("base64", encoded).length());
+ >= decode("base64", encoded).length()
+ );
}
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/utility/encoder/encoderFactoryTest.cpp b/tests/utility/encoder/encoderFactoryTest.cpp
index ce50dc6a..916706c9 100644
--- a/tests/utility/encoder/encoderFactoryTest.cpp
+++ b/tests/utility/encoder/encoderFactoryTest.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(encoderFactoryTest)
VMIME_TEST_LIST_END
- void testNoDefaultEncoder()
- {
+ void testNoDefaultEncoder() {
+
vmime::shared_ptr <vmime::utility::encoder::encoderFactory> ef =
vmime::utility::encoder::encoderFactory::getInstance();
@@ -47,8 +47,8 @@ VMIME_TEST_SUITE_BEGIN(encoderFactoryTest)
);
}
- void testDefaultEncoder()
- {
+ void testDefaultEncoder() {
+
vmime::shared_ptr <vmime::utility::encoder::encoderFactory> ef =
vmime::utility::encoder::encoderFactory::getInstance();
diff --git a/tests/utility/encoder/encoderTestUtils.hpp b/tests/utility/encoder/encoderTestUtils.hpp
index d74c4709..cc1141c7 100644
--- a/tests/utility/encoder/encoderTestUtils.hpp
+++ b/tests/utility/encoder/encoderTestUtils.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
@@ -23,25 +23,32 @@
// Helper function to obtain an encoder given its name
-static vmime::shared_ptr <vmime::utility::encoder::encoder> getEncoder(const vmime::string& name,
- int maxLineLength = 0, const vmime::propertySet props = vmime::propertySet())
-{
+static vmime::shared_ptr <vmime::utility::encoder::encoder> getEncoder(
+ const vmime::string& name,
+ int maxLineLength = 0,
+ const vmime::propertySet props = vmime::propertySet()
+) {
+
vmime::shared_ptr <vmime::utility::encoder::encoder> enc =
vmime::utility::encoder::encoderFactory::getInstance()->create(name);
enc->getProperties() = props;
- if (maxLineLength != 0)
+ if (maxLineLength != 0) {
enc->getProperties()["maxlinelength"] = maxLineLength;
+ }
return enc;
}
// Encoding helper function
-static const vmime::string encode(const vmime::string& name, const vmime::string& in,
- int maxLineLength = 0, const vmime::propertySet props = vmime::propertySet())
-{
+static const vmime::string encode(
+ const vmime::string& name, const vmime::string& in,
+ int maxLineLength = 0,
+ const vmime::propertySet props = vmime::propertySet()
+) {
+
vmime::shared_ptr <vmime::utility::encoder::encoder> enc = getEncoder(name, maxLineLength, props);
vmime::utility::inputStreamStringAdapter vin(in);
@@ -56,8 +63,12 @@ static const vmime::string encode(const vmime::string& name, const vmime::string
// Decoding helper function
-static const vmime::string decode(const vmime::string& name, const vmime::string& in, int maxLineLength = 0)
-{
+static const vmime::string decode(
+ const vmime::string& name,
+ const vmime::string& in,
+ int maxLineLength = 0
+) {
+
vmime::shared_ptr <vmime::utility::encoder::encoder> enc = getEncoder(name, maxLineLength);
vmime::utility::inputStreamStringAdapter vin(in);
diff --git a/tests/utility/encoder/qpEncoderTest.cpp b/tests/utility/encoder/qpEncoderTest.cpp
index e7d1bcd2..e4769475 100644
--- a/tests/utility/encoder/qpEncoderTest.cpp
+++ b/tests/utility/encoder/qpEncoderTest.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,10 +38,10 @@ VMIME_TEST_SUITE_BEGIN(qpEncoderTest)
VMIME_TEST_LIST_END
- void testQuotedPrintable()
- {
- static const vmime::string testSuites[] =
- {
+ void testQuotedPrintable() {
+
+ static const vmime::string testSuites[] = {
+
// Test 1
"",
@@ -94,8 +94,8 @@ VMIME_TEST_SUITE_BEGIN(qpEncoderTest)
};
- for (unsigned int i = 0 ; i < sizeof(testSuites) / sizeof(testSuites[0]) / 2 ; ++i)
- {
+ for (unsigned int i = 0 ; i < sizeof(testSuites) / sizeof(testSuites[0]) / 2 ; ++i) {
+
const vmime::string decoded = testSuites[i * 2];
const vmime::string encoded = testSuites[i * 2 + 1];
@@ -109,25 +109,36 @@ VMIME_TEST_SUITE_BEGIN(qpEncoderTest)
VASSERT_EQ(oss.str() + "decoding", decoded, decode("quoted-printable", encoded, 74));
// Multiple and successive encoding/decoding
- VASSERT_EQ(oss.str() + "multiple1", decoded,
+ VASSERT_EQ(
+ oss.str() + "multiple1",
+ decoded,
decode("quoted-printable",
- encode("quoted-printable", decoded)));
+ encode("quoted-printable", decoded))
+ );
- VASSERT_EQ(oss.str() + "multiple2", decoded,
+ VASSERT_EQ(
+ oss.str() + "multiple2",
+ decoded,
decode("quoted-printable",
decode("quoted-printable",
encode("quoted-printable",
- encode("quoted-printable", decoded)))));
+ encode("quoted-printable", decoded))))
+ );
- VASSERT_EQ(oss.str() + "multiple3", decoded,
+ VASSERT_EQ(
+ oss.str() + "multiple3",
+ decoded,
decode("quoted-printable",
decode("quoted-printable",
decode("quoted-printable",
encode("quoted-printable",
encode("quoted-printable",
- encode("quoted-printable", decoded)))))));
+ encode("quoted-printable", decoded))))))
+ );
- VASSERT_EQ(oss.str() + "multiple4", decoded,
+ VASSERT_EQ(
+ oss.str() + "multiple4",
+ decoded,
decode("quoted-printable",
decode("quoted-printable",
decode("quoted-printable",
@@ -135,38 +146,50 @@ VMIME_TEST_SUITE_BEGIN(qpEncoderTest)
encode("quoted-printable",
encode("quoted-printable",
encode("quoted-printable",
- encode("quoted-printable", decoded)))))))));
+ encode("quoted-printable", decoded))))))))
+ );
- VASSERT(oss.str() + "encoded size",
+ VASSERT(
+ oss.str() + "encoded size",
getEncoder("quoted-printable")->getEncodedSize(decoded.length())
- >= encode("quoted-printable", decoded).length());
+ >= encode("quoted-printable", decoded).length()
+ );
- VASSERT(oss.str() + "decoded size",
+ VASSERT(
+ oss.str() + "decoded size",
getEncoder("quoted-printable")->getDecodedSize(encoded.length())
- >= decode("quoted-printable", encoded).length());
+ >= decode("quoted-printable", encoded).length()
+ );
}
}
/** Tests Soft Line Breaks (RFC-2047/6.7(5). */
- void testQuotedPrintable_SoftLineBreaks()
- {
- VASSERT_EQ("1", "Now's the time=\r\n"
- " for all folk =\r\n"
- "to come to the=\r\n"
- " aid of their =\r\n"
- "country.",
- encode("quoted-printable", "Now's the time for all folk "
- "to come to the aid of their country.", 15));
+ void testQuotedPrintable_SoftLineBreaks() {
+
+ VASSERT_EQ(
+ "1",
+ "Now's the time=\r\n"
+ " for all folk =\r\n"
+ "to come to the=\r\n"
+ " aid of their =\r\n"
+ "country.",
+ encode(
+ "quoted-printable",
+ "Now's the time for all folk "
+ "to come to the aid of their country.",
+ 15
+ )
+ );
}
- void testQuotedPrintable_HardLineBreakEncode()
- {
+ void testQuotedPrintable_HardLineBreakEncode() {
+
const std::string data =
"If you believe that truth=beauty,"
" then surely mathematics\r\nis the most"
" beautiful branch of philosophy.";
- const std::string expected =
+ const std::string expected =
"If you believe that truth=3Dbeauty=\r\n"
", then surely mathematics\r\n"
"is the most beautiful branch of ph=\r\n"
@@ -178,14 +201,14 @@ VMIME_TEST_SUITE_BEGIN(qpEncoderTest)
VASSERT_EQ("1", expected, encode("quoted-printable", data, 35, encProps));
}
- void testQuotedPrintable_HardLineBreakDecode()
- {
+ void testQuotedPrintable_HardLineBreakDecode() {
+
const std::string expected =
"If you believe that truth=beauty,"
" then surely mathematics\r\nis the most"
" beautiful branch of philosophy.";
- const std::string data =
+ const std::string data =
"If you believe that truth=3Dbeauty=\r\n"
", then surely mathematics\r\n"
"is the most beautiful branch of ph=\r\n"
@@ -197,23 +220,29 @@ VMIME_TEST_SUITE_BEGIN(qpEncoderTest)
/** In text mode, ensure line breaks in QP-encoded text are represented
* by a CRLF sequence, as per RFC-2047/6.7(4). */
- void testQuotedPrintable_CRLF()
- {
+ void testQuotedPrintable_CRLF() {
+
vmime::propertySet encProps;
// in "text" mode
encProps["text"] = true;
- VASSERT_EQ("text", "line1\r\nline2",
- encode("quoted-printable", "line1\r\nline2", 80, encProps));
+ VASSERT_EQ(
+ "text",
+ "line1\r\nline2",
+ encode("quoted-printable", "line1\r\nline2", 80, encProps)
+ );
// in "binary" mode
encProps["text"] = false;
- VASSERT_EQ("binary", "line1=0D=0Aline2",
- encode("quoted-printable", "line1\r\nline2", 80, encProps));
+ VASSERT_EQ(
+ "binary",
+ "line1=0D=0Aline2",
+ encode("quoted-printable", "line1\r\nline2", 80, encProps)
+ );
}
- void testQuotedPrintable_RFC2047()
- {
+ void testQuotedPrintable_RFC2047() {
+
/*
* The RFC (http://tools.ietf.org/html/rfc2047#section-5) says:
*
@@ -243,6 +272,4 @@ VMIME_TEST_SUITE_BEGIN(qpEncoderTest)
VASSERT_EQ("especials.12", "=22", encode("quoted-printable", "\"", 10, encProps));
}
- // TODO: UUEncode
-
VMIME_TEST_SUITE_END
diff --git a/tests/utility/filteredStreamTest.cpp b/tests/utility/filteredStreamTest.cpp
index cedfab2a..ff3fb6a3 100644
--- a/tests/utility/filteredStreamTest.cpp
+++ b/tests/utility/filteredStreamTest.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,8 +41,8 @@ VMIME_TEST_SUITE_BEGIN(filteredStreamTest)
VMIME_TEST_LIST_END
- class chunkInputStream : public vmime::utility::inputStream
- {
+ class chunkInputStream : public vmime::utility::inputStream {
+
private:
std::vector <std::string> m_chunks;
@@ -57,10 +57,11 @@ VMIME_TEST_SUITE_BEGIN(filteredStreamTest)
bool eof() const { return (m_index >= m_chunks.size()); }
void reset() { m_index = 0; }
- vmime::size_t read(vmime::byte_t* const data, const vmime::size_t /* count */)
- {
- if (eof())
+ vmime::size_t read(vmime::byte_t* const data, const vmime::size_t /* count */) {
+
+ if (eof()) {
return 0;
+ }
const std::string chunk = m_chunks[m_index];
@@ -73,37 +74,41 @@ VMIME_TEST_SUITE_BEGIN(filteredStreamTest)
return chunk.length();
}
- vmime::size_t skip(const vmime::size_t /* count */)
- {
+ vmime::size_t skip(const vmime::size_t /* count */) {
+
// Not supported
return 0;
}
};
- const std::string readWhole(vmime::utility::inputStream& is)
- {
+ const std::string readWhole(vmime::utility::inputStream& is) {
+
vmime::byte_t buffer[256];
std::string whole;
- while (!is.eof())
- {
+ while (!is.eof()) {
+
const vmime::size_t read = is.read(buffer, sizeof(buffer));
whole += vmime::utility::stringUtils::makeStringFromBytes(buffer, read);
}
- return (whole);
+ return whole;
}
// dotFilteredInputStream
- void testDotFilteredInputStreamHelper
- (const std::string& number, const std::string& expected,
- const std::string& c1, const std::string& c2 = "",
- const std::string& c3 = "", const std::string& c4 = "")
- {
+ void testDotFilteredInputStreamHelper(
+ const std::string& number,
+ const std::string& expected,
+ const std::string& c1,
+ const std::string& c2 = "",
+ const std::string& c3 = "",
+ const std::string& c4 = ""
+ ) {
+
chunkInputStream cis;
cis.addChunk(c1);
if (!c2.empty()) cis.addChunk(c2);
@@ -120,8 +125,8 @@ VMIME_TEST_SUITE_BEGIN(filteredStreamTest)
VASSERT_EQ(number, expected, oss.str());
}
- void testDotFilteredInputStream()
- {
+ void testDotFilteredInputStream() {
+
testDotFilteredInputStreamHelper("1", "foo\n.bar", "foo\n..bar");
testDotFilteredInputStreamHelper("2", "foo\n.bar", "foo\n", "..bar");
testDotFilteredInputStreamHelper("3", "foo\n.bar", "foo\n.", ".bar");
@@ -140,11 +145,15 @@ VMIME_TEST_SUITE_BEGIN(filteredStreamTest)
// CRLFToLFFilteredOutputStream
template <typename FILTER>
- void testFilteredOutputStreamHelper
- (const std::string& number, const std::string& expected,
- const std::string& c1, const std::string& c2 = "",
- const std::string& c3 = "", const std::string& c4 = "")
- {
+ void testFilteredOutputStreamHelper(
+ const std::string& number,
+ const std::string& expected,
+ const std::string& c1,
+ const std::string& c2 = "",
+ const std::string& c3 = "",
+ const std::string& c4 = ""
+ ) {
+
std::ostringstream oss;
vmime::utility::outputStreamAdapter os(oss);
@@ -158,8 +167,8 @@ VMIME_TEST_SUITE_BEGIN(filteredStreamTest)
VASSERT_EQ(number, expected, oss.str());
}
- void testDotFilteredOutputStream()
- {
+ void testDotFilteredOutputStream() {
+
typedef vmime::utility::dotFilteredOutputStream FILTER;
testFilteredOutputStreamHelper<FILTER>("1", "foo\n..bar", "foo\n.bar");
@@ -177,8 +186,8 @@ VMIME_TEST_SUITE_BEGIN(filteredStreamTest)
testFilteredOutputStreamHelper<FILTER>("11", "this is the first line\x0d\x0a...\x0d\x0aone dot\x0d\x0a....\x0d\x0atwo dots\x0d\x0a.....\x0d\x0athree... \x0d\x0a...\x0d\x0a..\x0d\x0a", "this is the first line\x0d\x0a..\x0d\x0aone dot\x0d\x0a...\x0d\x0atwo dots\x0d\x0a....\x0d\x0athree... \x0d\x0a..\x0d\x0a.\x0d\x0a");
}
- void testCRLFToLFFilteredOutputStream()
- {
+ void testCRLFToLFFilteredOutputStream() {
+
typedef vmime::utility::CRLFToLFFilteredOutputStream FILTER;
testFilteredOutputStreamHelper<FILTER>("1", "foo\nbar", "foo\r\nbar");
@@ -193,12 +202,17 @@ VMIME_TEST_SUITE_BEGIN(filteredStreamTest)
// stopSequenceFilteredInputStream
template <int N>
- void testStopSequenceFISHelper
- (const std::string& number, const std::string& sequence,
- const std::string& expected, const std::string& c1,
- const std::string& c2 = "", const std::string& c3 = "",
- const std::string& c4 = "", const std::string& c5 = "")
- {
+ void testStopSequenceFISHelper(
+ const std::string& number,
+ const std::string& sequence,
+ const std::string& expected,
+ const std::string& c1,
+ const std::string& c2 = "",
+ const std::string& c3 = "",
+ const std::string& c4 = "",
+ const std::string& c5 = ""
+ ) {
+
chunkInputStream cis;
cis.addChunk(c1);
if (!c2.empty()) cis.addChunk(c2);
@@ -211,8 +225,8 @@ VMIME_TEST_SUITE_BEGIN(filteredStreamTest)
VASSERT_EQ(number, expected, readWhole(is));
}
- void testStopSequenceFilteredInputStream1()
- {
+ void testStopSequenceFilteredInputStream1() {
+
testStopSequenceFISHelper <1>("1", "x", "foo", "fooxbar");
testStopSequenceFISHelper <1>("2", "x", "foo", "foox", "bar");
testStopSequenceFISHelper <1>("3", "x", "foo", "foo", "x", "bar");
@@ -231,8 +245,8 @@ VMIME_TEST_SUITE_BEGIN(filteredStreamTest)
testStopSequenceFISHelper <1>("13", "x", "", "", "x");
}
- void testStopSequenceFilteredInputStreamN_2()
- {
+ void testStopSequenceFilteredInputStreamN_2() {
+
testStopSequenceFISHelper <2>("1", "xy", "foo", "fooxybar");
testStopSequenceFISHelper <2>("2", "xy", "foo", "foox", "ybar");
testStopSequenceFISHelper <2>("3", "xy", "foo", "foox", "y", "bar");
@@ -255,8 +269,8 @@ VMIME_TEST_SUITE_BEGIN(filteredStreamTest)
testStopSequenceFISHelper <2>("17", "xy", "", "x", "y");
}
- void testStopSequenceFilteredInputStreamN_3()
- {
+ void testStopSequenceFilteredInputStreamN_3() {
+
testStopSequenceFISHelper <3>("1", "xyz", "foo", "fooxyzbar");
testStopSequenceFISHelper <3>("2", "xyz", "foo", "foox", "yzbar");
testStopSequenceFISHelper <3>("3", "xyz", "foo", "foox", "y", "zbar");
@@ -289,8 +303,8 @@ VMIME_TEST_SUITE_BEGIN(filteredStreamTest)
// LFToCRLFFilteredOutputStream
- void testLFToCRLFFilteredOutputStream_Global()
- {
+ void testLFToCRLFFilteredOutputStream_Global() {
+
typedef vmime::utility::LFToCRLFFilteredOutputStream FILTER;
testFilteredOutputStreamHelper<FILTER>("1", "ABC\r\nDEF", "ABC\nDEF");
@@ -306,8 +320,8 @@ VMIME_TEST_SUITE_BEGIN(filteredStreamTest)
testFilteredOutputStreamHelper<FILTER>("11", "\r\n\r\n\r\n\r\n", "\n\n\n\r\n");
}
- void testLFToCRLFFilteredOutputStream_Edge()
- {
+ void testLFToCRLFFilteredOutputStream_Edge() {
+
typedef vmime::utility::LFToCRLFFilteredOutputStream FILTER;
testFilteredOutputStreamHelper<FILTER>("1", "\r\n\r\n", "\r", "\r");
@@ -325,4 +339,3 @@ VMIME_TEST_SUITE_BEGIN(filteredStreamTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/utility/outputStreamByteArrayAdapterTest.cpp b/tests/utility/outputStreamByteArrayAdapterTest.cpp
index b14d0a39..07a0f4b9 100644
--- a/tests/utility/outputStreamByteArrayAdapterTest.cpp
+++ b/tests/utility/outputStreamByteArrayAdapterTest.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(outputStreamByteArrayAdapterTest)
VMIME_TEST_LIST_END
- void testWrite()
- {
+ void testWrite() {
+
vmime::byteArray bytes;
vmime::utility::outputStreamByteArrayAdapter stream(bytes);
@@ -50,8 +50,8 @@ VMIME_TEST_SUITE_BEGIN(outputStreamByteArrayAdapterTest)
VASSERT_EQ("Write 2", 0, memcmp("some datamore data", &bytes[0], 18));
}
- void testWriteBinary()
- {
+ void testWriteBinary() {
+
const char binaryData[] =
"\xc5\x9a\xc3\xb8\xc9\xb1\xc9\x9b\x20\xc9\x93\xc9\xa8\xc9\xb2\xc9"
"\x91\xc5\x95\xc9\xa3\x20\xc9\x96\xc9\x90\xca\x88\xc9\x92";
@@ -65,8 +65,8 @@ VMIME_TEST_SUITE_BEGIN(outputStreamByteArrayAdapterTest)
VASSERT_EQ("Write", 0, memcmp(binaryData, &bytes[0], sizeof(binaryData)));
}
- void testWriteCRLF()
- {
+ void testWriteCRLF() {
+
vmime::byteArray bytes;
vmime::utility::outputStreamByteArrayAdapter stream(bytes);
@@ -80,4 +80,3 @@ VMIME_TEST_SUITE_BEGIN(outputStreamByteArrayAdapterTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/utility/outputStreamSocketAdapterTest.cpp b/tests/utility/outputStreamSocketAdapterTest.cpp
index 4920a75c..a869ed74 100644
--- a/tests/utility/outputStreamSocketAdapterTest.cpp
+++ b/tests/utility/outputStreamSocketAdapterTest.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(outputStreamSocketAdapterTest)
VMIME_TEST_LIST_END
- void testWrite()
- {
+ void testWrite() {
+
vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
vmime::utility::outputStreamSocketAdapter stream(*socket);
@@ -49,8 +49,8 @@ VMIME_TEST_SUITE_BEGIN(outputStreamSocketAdapterTest)
VASSERT_EQ("Write", "some data", buffer);
}
- void testWriteBinary()
- {
+ void testWriteBinary() {
+
const char binaryData[] =
"\xc5\x9a\xc3\xb8\xc9\xb1\xc9\x9b\x20\xc9\x93\xc9\xa8\xc9\xb2\xc9"
"\x91\xc5\x95\xc9\xa3\x20\xc9\x96\xc9\x90\xca\x88\xc9\x92";
@@ -67,8 +67,8 @@ VMIME_TEST_SUITE_BEGIN(outputStreamSocketAdapterTest)
VASSERT_EQ("Write", 0, memcmp(binaryData, buffer.data(), sizeof(binaryData)));
}
- void testWriteCRLF()
- {
+ void testWriteCRLF() {
+
vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
vmime::utility::outputStreamSocketAdapter stream(*socket);
@@ -85,4 +85,3 @@ VMIME_TEST_SUITE_BEGIN(outputStreamSocketAdapterTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/utility/outputStreamStringAdapterTest.cpp b/tests/utility/outputStreamStringAdapterTest.cpp
index 1cd3b3a0..3de8f8b8 100644
--- a/tests/utility/outputStreamStringAdapterTest.cpp
+++ b/tests/utility/outputStreamStringAdapterTest.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(outputStreamStringAdapterTest)
VMIME_TEST_LIST_END
- void testWrite()
- {
+ void testWrite() {
+
vmime::string str("initial data");
vmime::utility::outputStreamStringAdapter stream(str);
@@ -52,8 +52,8 @@ VMIME_TEST_SUITE_BEGIN(outputStreamStringAdapterTest)
VASSERT_EQ("Write 2 data", "initial dataadditional datamore data", str);
}
- void testWriteBinary()
- {
+ void testWriteBinary() {
+
const vmime::byte_t binaryData[] =
"\xc5\x9a\xc3\xb8\xc9\xb1\xc9\x9b\x20\xc9\x93\xc9\xa8\xc9\xb2\xc9"
"\x91\xc5\x95\xc9\xa3\x20\xc9\x96\xc9\x90\xca\x88\xc9\x92";
@@ -67,8 +67,8 @@ VMIME_TEST_SUITE_BEGIN(outputStreamStringAdapterTest)
VASSERT_EQ("Write", 0, memcmp(binaryData, str.data(), sizeof(binaryData)));
}
- void testWriteCRLF()
- {
+ void testWriteCRLF() {
+
vmime::string str;
vmime::utility::outputStreamStringAdapter stream(str);
@@ -82,4 +82,3 @@ VMIME_TEST_SUITE_BEGIN(outputStreamStringAdapterTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/utility/parserInputStreamAdapterTest.cpp b/tests/utility/parserInputStreamAdapterTest.cpp
index 0fd4f4e8..4bc310c9 100644
--- a/tests/utility/parserInputStreamAdapterTest.cpp
+++ b/tests/utility/parserInputStreamAdapterTest.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(parserInputStreamAdapterTest)
VMIME_TEST_LIST_END
- void testEndlessLoopBufferSize()
- {
+ void testEndlessLoopBufferSize() {
+
static const unsigned int BUFFER_SIZE = 4096; // same as in parserInputStreamAdapter::findNext()
vmime::string str(BUFFER_SIZE, 'X');
diff --git a/tests/utility/pathTest.cpp b/tests/utility/pathTest.cpp
index ef1b773d..e6227f3a 100644
--- a/tests/utility/pathTest.cpp
+++ b/tests/utility/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
@@ -64,14 +64,14 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
typedef vmime::utility::path::component comp;
- void testConstruct1()
- {
+ void testConstruct1() {
+
VASSERT_EQ("1", true, path().isEmpty());
VASSERT_EQ("2", 0, path().getSize());
}
- void testConstruct2()
- {
+ void testConstruct2() {
+
path p(comp("foo"));
VASSERT_EQ("1", false, p.isEmpty());
@@ -79,8 +79,8 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("3", "foo", p.getComponentAt(0).getBuffer());
}
- void testAppendComponent()
- {
+ void testAppendComponent() {
+
path p;
VASSERT_EQ("1", 0, p.getSize());
@@ -92,8 +92,8 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("3", c.getBuffer(), p.getComponentAt(0).getBuffer());
}
- void testConstruct3()
- {
+ void testConstruct3() {
+
path p1;
p1.appendComponent(comp("foo"));
p1.appendComponent(comp("bar"));
@@ -105,8 +105,8 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("3", "bar", p2.getComponentAt(1).getBuffer());
}
- void testConstruct4()
- {
+ void testConstruct4() {
+
// Same as path::path(const component&)
path p("foo");
@@ -115,8 +115,8 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("3", "foo", p.getComponentAt(0).getBuffer());
}
- void testOperatorDiv1()
- {
+ void testOperatorDiv1() {
+
path p1;
p1.appendComponent(comp("foo"));
p1.appendComponent(comp("bar"));
@@ -132,8 +132,8 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("4", p2.getComponentAt(0).getBuffer(), p3.getComponentAt(2).getBuffer());
}
- void testOperatorDiv2()
- {
+ void testOperatorDiv2() {
+
path p1;
p1.appendComponent(comp("foo"));
p1.appendComponent(comp("bar"));
@@ -148,8 +148,8 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("4", c.getBuffer(), p2.getComponentAt(2).getBuffer());
}
- void testOperatorDivEqual1()
- {
+ void testOperatorDivEqual1() {
+
path p1;
p1.appendComponent(comp("foo"));
p1.appendComponent(comp("bar"));
@@ -166,8 +166,8 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("4", p2.getComponentAt(0).getBuffer(), p3.getComponentAt(2).getBuffer());
}
- void testOperatorDivEqual2()
- {
+ void testOperatorDivEqual2() {
+
path p1;
p1.appendComponent(comp("foo"));
p1.appendComponent(comp("bar"));
@@ -183,8 +183,8 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("4", c.getBuffer(), p2.getComponentAt(2).getBuffer());
}
- void testGetParent()
- {
+ void testGetParent() {
+
path p1;
path p1p = p1.getParent();
@@ -200,8 +200,8 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("3", p2.getComponentAt(0).getBuffer(), p2p.getComponentAt(0).getBuffer());
}
- void testComparison()
- {
+ void testComparison() {
+
path p1;
p1.appendComponent(comp("foo"));
p1.appendComponent(comp("bar"));
@@ -224,8 +224,8 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("5", true, p3.getParent() == p1);
}
- void testGetLastComponent()
- {
+ void testGetLastComponent() {
+
path p1;
p1.appendComponent(comp("foo"));
p1.appendComponent(comp("bar"));
@@ -236,8 +236,8 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("3", "foo", p1.getParent().getParent().getLastComponent().getBuffer());
}
- void testIsDirectParentOf()
- {
+ void testIsDirectParentOf() {
+
path p1;
p1.appendComponent(comp("foo"));
@@ -256,8 +256,8 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("4", false, p2.isDirectParentOf(p1));
}
- void testIsParentOf()
- {
+ void testIsParentOf() {
+
path p1;
p1.appendComponent(comp("foo"));
@@ -276,8 +276,8 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("4", false, p2.isParentOf(p1));
}
- void testIsParentOf_EquivalentCharset()
- {
+ void testIsParentOf_EquivalentCharset() {
+
path p1;
p1.appendComponent(comp("foo", "us-ascii"));
@@ -289,8 +289,8 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("1", true, p1.isParentOf(p2));
}
- void testRenameParent()
- {
+ void testRenameParent() {
+
path p1;
p1.appendComponent(comp("a"));
p1.appendComponent(comp("b"));
@@ -317,8 +317,8 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("6", "d", p.getComponentAt(4).getBuffer());
}
- void testFromString()
- {
+ void testFromString() {
+
path p = path::fromString("ab/cde/f", "/", vmime::charset("my-charset"));
VASSERT_EQ("count", 3, p.getSize());
@@ -330,8 +330,8 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("charset3", "my-charset", p.getComponentAt(2).getCharset().getName());
}
- void testFromString_IgnoreLeadingOrTrailingSep()
- {
+ void testFromString_IgnoreLeadingOrTrailingSep() {
+
path p = path::fromString("//ab/cde/f////", "/", vmime::charset("my-charset"));
VASSERT_EQ("count", 3, p.getSize());
@@ -343,8 +343,8 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("charset3", "my-charset", p.getComponentAt(2).getCharset().getName());
}
- void testToString()
- {
+ void testToString() {
+
path p;
p.appendComponent(comp("ab"));
p.appendComponent(comp("cde"));
@@ -354,4 +354,3 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/utility/seekableInputStreamRegionAdapterTest.cpp b/tests/utility/seekableInputStreamRegionAdapterTest.cpp
index e703051b..b099cd77 100644
--- a/tests/utility/seekableInputStreamRegionAdapterTest.cpp
+++ b/tests/utility/seekableInputStreamRegionAdapterTest.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
@@ -43,9 +43,10 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest)
VMIME_TEST_LIST_END
- vmime::shared_ptr <seekableInputStreamRegionAdapter> createStream
- (vmime::shared_ptr <seekableInputStream>* underlyingStream = NULL)
- {
+ vmime::shared_ptr <seekableInputStreamRegionAdapter> createStream(
+ vmime::shared_ptr <seekableInputStream>* underlyingStream = NULL
+ ) {
+
vmime::string buffer("THIS IS A TEST BUFFER");
vmime::shared_ptr <seekableInputStream> strStream =
@@ -54,22 +55,23 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest)
vmime::shared_ptr <seekableInputStreamRegionAdapter> rgnStream =
vmime::make_shared <seekableInputStreamRegionAdapter>(strStream, 10, 11);
- if (underlyingStream)
+ if (underlyingStream) {
*underlyingStream = strStream;
+ }
return rgnStream;
}
- void testInitialPosition()
- {
+ void testInitialPosition() {
+
vmime::shared_ptr <seekableInputStreamRegionAdapter> stream = createStream();
VASSERT_EQ("Pos", 0, stream->getPosition());
VASSERT_FALSE("EOF", stream->eof());
}
- void testSeekAndGetPosition()
- {
+ void testSeekAndGetPosition() {
+
vmime::shared_ptr <seekableInputStreamRegionAdapter> stream = createStream();
stream->seek(5);
@@ -83,8 +85,8 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest)
VASSERT_TRUE("EOF 2", stream->eof());
}
- void testRead()
- {
+ void testRead() {
+
vmime::shared_ptr <seekableInputStreamRegionAdapter> stream = createStream();
stream->seek(5);
@@ -96,12 +98,11 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest)
VASSERT_EQ("Pos", 11, stream->getPosition());
VASSERT_EQ("Read", 6, read);
VASSERT_TRUE("EOF", stream->eof());
- VASSERT_EQ("Buffer", "BUFFER",
- vmime::utility::stringUtils::makeStringFromBytes(buffer, 6));
+ VASSERT_EQ("Buffer", "BUFFER", vmime::utility::stringUtils::makeStringFromBytes(buffer, 6));
}
- void testSkip()
- {
+ void testSkip() {
+
vmime::shared_ptr <seekableInputStreamRegionAdapter> stream = createStream();
stream->skip(5);
@@ -116,8 +117,7 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest)
VASSERT_EQ("Pos 2", 8, stream->getPosition());
VASSERT_EQ("Read", 3, read);
VASSERT_FALSE("EOF 2", stream->eof());
- VASSERT_EQ("Buffer", "BUF",
- vmime::utility::stringUtils::makeStringFromBytes(buffer, 3));
+ VASSERT_EQ("Buffer", "BUF", vmime::utility::stringUtils::makeStringFromBytes(buffer, 3));
stream->skip(50);
@@ -125,8 +125,8 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest)
VASSERT_TRUE("EOF 3", stream->eof());
}
- void testReset()
- {
+ void testReset() {
+
vmime::shared_ptr <seekableInputStreamRegionAdapter> stream = createStream();
stream->skip(100);
@@ -136,8 +136,8 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest)
VASSERT_FALSE("EOF", stream->eof());
}
- void testOwnPosition()
- {
+ void testOwnPosition() {
+
// seekableInputStreamRegionAdapter should keep track of its own position
// in the underlying stream, and not be affected by possible seek/read
// operations on it...
@@ -156,10 +156,17 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest)
VASSERT_EQ("Read 2", 6, stream->read(buffer2, 6));
- VASSERT_EQ("Buffer 1", "THIS IS",
- vmime::utility::stringUtils::makeStringFromBytes(buffer1, 7));
- VASSERT_EQ("Buffer 2", "BUFFER",
- vmime::utility::stringUtils::makeStringFromBytes(buffer2, 6));
+ VASSERT_EQ(
+ "Buffer 1",
+ "THIS IS",
+ vmime::utility::stringUtils::makeStringFromBytes(buffer1, 7)
+ );
+
+ VASSERT_EQ(
+ "Buffer 2",
+ "BUFFER",
+ vmime::utility::stringUtils::makeStringFromBytes(buffer2, 6)
+ );
// ...but the underlying stream position is affected by read operations
// from the region adapter (FIXME?)
diff --git a/tests/utility/stringProxyTest.cpp b/tests/utility/stringProxyTest.cpp
index d6513681..89b96568 100644
--- a/tests/utility/stringProxyTest.cpp
+++ b/tests/utility/stringProxyTest.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,8 +41,8 @@ VMIME_TEST_SUITE_BEGIN(stringProxyTest)
VMIME_TEST_LIST_END
- void testConstruct()
- {
+ void testConstruct() {
+
vmime::utility::stringProxy s;
VASSERT_EQ("1", static_cast <vmime::size_t>(0), s.length());
@@ -50,8 +50,8 @@ VMIME_TEST_SUITE_BEGIN(stringProxyTest)
VASSERT_EQ("3", static_cast <vmime::size_t>(0), s.end());
}
- void testConstruct2()
- {
+ void testConstruct2() {
+
vmime::string str("This is a test string.");
vmime::utility::stringProxy s1(str);
@@ -78,8 +78,8 @@ VMIME_TEST_SUITE_BEGIN(stringProxyTest)
VASSERT_EQ("13", 't', *(s3.it_begin() + 3));
}
- void testDetach()
- {
+ void testDetach() {
+
vmime::utility::stringProxy s;
s = "foo";
@@ -90,8 +90,8 @@ VMIME_TEST_SUITE_BEGIN(stringProxyTest)
VASSERT_EQ("3", static_cast <vmime::size_t>(0), s.end());
}
- void testSet()
- {
+ void testSet() {
+
vmime::string str("This is a test string.");
vmime::utility::stringProxy s1;
@@ -121,8 +121,8 @@ VMIME_TEST_SUITE_BEGIN(stringProxyTest)
VASSERT_EQ("13", 't', *(s3.it_begin() + 3));
}
- void testExtract()
- {
+ void testExtract() {
+
vmime::string str("This is a test string.");
vmime::utility::stringProxy s1(str, 10, 14);
@@ -144,8 +144,8 @@ VMIME_TEST_SUITE_BEGIN(stringProxyTest)
VASSERT_EQ("2", str, oss2.str());
}
- void testOperatorLTLT1()
- {
+ void testOperatorLTLT1() {
+
vmime::string str("This is a test string.");
vmime::utility::stringProxy s1(str, 10, 14);
@@ -163,8 +163,8 @@ VMIME_TEST_SUITE_BEGIN(stringProxyTest)
VASSERT_EQ("2", str, oss2.str());
}
- void testOperatorLTLT2()
- {
+ void testOperatorLTLT2() {
+
vmime::string str("This is a test string.");
vmime::utility::stringProxy s1(str, 10, 14);
@@ -187,4 +187,3 @@ VMIME_TEST_SUITE_BEGIN(stringProxyTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/utility/stringUtilsTest.cpp b/tests/utility/stringUtilsTest.cpp
index d86bbda0..393482f3 100644
--- a/tests/utility/stringUtilsTest.cpp
+++ b/tests/utility/stringUtilsTest.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,8 +52,8 @@ VMIME_TEST_SUITE_BEGIN(stringUtilsTest)
typedef vmime::utility::stringUtils stringUtils;
- void testMakeStringFromBytes()
- {
+ void testMakeStringFromBytes() {
+
vmime::byte_t bytes[] = { 0x12, 0x34, 0x56, 0x78 };
vmime::string str = vmime::utility::stringUtils::makeStringFromBytes(bytes, 3);
@@ -63,8 +63,8 @@ VMIME_TEST_SUITE_BEGIN(stringUtilsTest)
VASSERT_EQ("byte3", '\x56', str[2]);
}
- void testAppendBytesToString()
- {
+ void testAppendBytesToString() {
+
vmime::byte_t bytes[] = { 0x42, 0x56, 0x12, 0x00, 'f', 'o', 'o' };
vmime::string str = "test";
@@ -84,8 +84,8 @@ VMIME_TEST_SUITE_BEGIN(stringUtilsTest)
VASSERT_EQ("byte11", 'o', str[10]);
}
- void testIsStringEqualNoCase1()
- {
+ void testIsStringEqualNoCase1() {
+
VASSERT_EQ("1", true, stringUtils::isStringEqualNoCase(vmime::string("foo"), "foo", 3));
VASSERT_EQ("2", true, stringUtils::isStringEqualNoCase(vmime::string("FOo"), "foo", 3));
@@ -93,15 +93,15 @@ VMIME_TEST_SUITE_BEGIN(stringUtilsTest)
VASSERT_EQ("4", false, stringUtils::isStringEqualNoCase(vmime::string("foo"), "bar", 3));
}
- void testIsStringEqualNoCase2()
- {
+ void testIsStringEqualNoCase2() {
+
VASSERT_EQ("1", true, stringUtils::isStringEqualNoCase(vmime::string("foo"), vmime::string("foo")));
VASSERT_EQ("2", true, stringUtils::isStringEqualNoCase(vmime::string("FOo"), vmime::string("foo")));
VASSERT_EQ("3", true, stringUtils::isStringEqualNoCase(vmime::string("foO"), vmime::string("FOo")));
}
- void testIsStringEqualNoCase3()
- {
+ void testIsStringEqualNoCase3() {
+
vmime::string str1("FooBar");
VASSERT_EQ("1", true, stringUtils::isStringEqualNoCase(str1.begin(), str1.end(), "foobar", 6));
@@ -110,15 +110,15 @@ VMIME_TEST_SUITE_BEGIN(stringUtilsTest)
VASSERT_EQ("4", false, stringUtils::isStringEqualNoCase(str1.begin(), str1.begin() + 3, "fooBar", 6));
}
- void testToLower()
- {
+ void testToLower() {
+
VASSERT_EQ("1", "foo", stringUtils::toLower("FOO"));
VASSERT_EQ("2", "foo", stringUtils::toLower("foO"));
VASSERT_EQ("3", "foo", stringUtils::toLower("foo"));
}
- void testTrim()
- {
+ void testTrim() {
+
VASSERT_EQ("1", "foo", stringUtils::trim(" foo"));
VASSERT_EQ("2", "foo", stringUtils::trim("\t\tfoo"));
VASSERT_EQ("3", "foo", stringUtils::trim(" \t \tfoo"));
@@ -136,35 +136,47 @@ VMIME_TEST_SUITE_BEGIN(stringUtilsTest)
VASSERT_EQ("13", "foo", stringUtils::trim("\r \tfoo \n\t"));
}
- void testCountASCIIChars()
- {
+ void testCountASCIIChars() {
+
vmime::string str1("foo");
- VASSERT_EQ("1", static_cast <vmime::size_t>(3),
- stringUtils::countASCIIchars(str1.begin(), str1.end()));
+ VASSERT_EQ(
+ "1",
+ static_cast <vmime::size_t>(3),
+ stringUtils::countASCIIchars(str1.begin(), str1.end())
+ );
vmime::string str2("f=?oo");
- VASSERT_EQ("2", static_cast <vmime::size_t>(3 + 1),
- stringUtils::countASCIIchars(str2.begin(), str2.end()));
+ VASSERT_EQ(
+ "2",
+ static_cast <vmime::size_t>(3 + 1),
+ stringUtils::countASCIIchars(str2.begin(), str2.end())
+ );
vmime::string str3("foo\x7f");
- VASSERT_EQ("3", static_cast <vmime::size_t>(4),
- stringUtils::countASCIIchars(str3.begin(), str3.end()));
+ VASSERT_EQ(
+ "3",
+ static_cast <vmime::size_t>(4),
+ stringUtils::countASCIIchars(str3.begin(), str3.end())
+ );
vmime::string str4("foo\x80");
- VASSERT_EQ("4", static_cast <vmime::size_t>(3),
- stringUtils::countASCIIchars(str4.begin(), str4.end()));
+ VASSERT_EQ(
+ "4",
+ static_cast <vmime::size_t>(3),
+ stringUtils::countASCIIchars(str4.begin(), str4.end())
+ );
}
- void testUnquote()
- {
+ void testUnquote() {
+
VASSERT_EQ("1", "quoted", stringUtils::unquote("\"quoted\"")); // "quoted"
VASSERT_EQ("2", "\"not quoted", stringUtils::unquote("\"not quoted")); // "not quoted
VASSERT_EQ("3", "not quoted\"", stringUtils::unquote("not quoted\"")); // not quoted"
VASSERT_EQ("4", "quoted with \"escape\"", stringUtils::unquote("\"quoted with \\\"escape\\\"\"")); // "quoted with \"escape\""
}
- void testIsValidHostname()
- {
+ void testIsValidHostname() {
+
VASSERT_TRUE ("1", stringUtils::isValidHostname("localhost"));
VASSERT_TRUE ("2", stringUtils::isValidHostname("localhost.localdomain"));
VASSERT_TRUE ("3", stringUtils::isValidHostname("example.com"));
@@ -176,8 +188,8 @@ VMIME_TEST_SUITE_BEGIN(stringUtilsTest)
VASSERT_FALSE("9", stringUtils::isValidHostname("-example.com"));
}
- void testIsValidFQDN()
- {
+ void testIsValidFQDN() {
+
VASSERT_FALSE("1", stringUtils::isValidFQDN("localhost"));
VASSERT_FALSE("2", stringUtils::isValidFQDN("localhost.localdomain"));
VASSERT_FALSE("3", stringUtils::isValidFQDN("example.com"));
@@ -189,4 +201,3 @@ VMIME_TEST_SUITE_BEGIN(stringUtilsTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/utility/urlTest.cpp b/tests/utility/urlTest.cpp
index 85991511..36820a68 100644
--- a/tests/utility/urlTest.cpp
+++ b/tests/utility/urlTest.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
@@ -44,14 +44,14 @@ VMIME_TEST_SUITE_BEGIN(urlTest)
VMIME_TEST_LIST_END
- static bool parseHelper(vmime::utility::url& u, const vmime::string& str)
- {
- try
- {
+ static bool parseHelper(vmime::utility::url& u, const vmime::string& str) {
+
+ try {
+
u = vmime::utility::url(str);
- }
- catch (vmime::exceptions::malformed_url)
- {
+
+ } catch (vmime::exceptions::malformed_url) {
+
return false;
}
@@ -59,8 +59,8 @@ VMIME_TEST_SUITE_BEGIN(urlTest)
}
- void testParse1()
- {
+ void testParse1() {
+
// Test some valid constructions
vmime::utility::url u1("", "");
@@ -123,8 +123,8 @@ VMIME_TEST_SUITE_BEGIN(urlTest)
VASSERT_EQ("6.7", "/path/file", u4.getPath());
}
- void testParse2()
- {
+ void testParse2() {
+
// Now, test some ill-formed URLs
// -- missing protocol
@@ -144,8 +144,8 @@ VMIME_TEST_SUITE_BEGIN(urlTest)
VASSERT_EQ("4", false, parseHelper(u4, "protohost/path"));
}
- void testParse3()
- {
+ void testParse3() {
+
// Test decoding
vmime::utility::url u1("", "");
@@ -158,8 +158,8 @@ VMIME_TEST_SUITE_BEGIN(urlTest)
VASSERT_EQ("1.7", "/pa\xabth/", u1.getPath());
}
- void testParse4()
- {
+ void testParse4() {
+
// Test parameters
vmime::utility::url u1("", "");
@@ -191,8 +191,8 @@ VMIME_TEST_SUITE_BEGIN(urlTest)
}
// '@' symbol in the username part
- void testParse5()
- {
+ void testParse5() {
+
vmime::utility::url u1("", "");
VASSERT_EQ("1", true, parseHelper(u1, "imap://[email protected]:[email protected]"));
@@ -201,42 +201,54 @@ VMIME_TEST_SUITE_BEGIN(urlTest)
VASSERT_EQ("4", "myserver.com", u1.getHost());
}
- void testGenerate()
- {
+ void testGenerate() {
+
vmime::utility::url u1("proto", "host", 12345, "path", "user", "password");
- VASSERT_EQ("1", "proto://user:password@host:12345/path",
- static_cast <vmime::string>(u1));
+ VASSERT_EQ(
+ "1",
+ "proto://user:password@host:12345/path",
+ static_cast <vmime::string>(u1)
+ );
vmime::utility::url u2("proto", "host");
VASSERT_EQ("2", "proto://host", static_cast <vmime::string>(u2));
vmime::utility::url u3("proto", "host");
u3.getParams()["p1"] = "v1";
- VASSERT_EQ("3.1", "proto://host/?p1=v1",
- static_cast <vmime::string>(u3));
+ VASSERT_EQ(
+ "3.1",
+ "proto://host/?p1=v1",
+ static_cast <vmime::string>(u3)
+ );
u3.getParams()["p2"] = "v2";
- VASSERT_EQ("3.2", "proto://host/?p1=v1&p2=v2",
- static_cast <vmime::string>(u3));
+ VASSERT_EQ(
+ "3.2",
+ "proto://host/?p1=v1&p2=v2",
+ static_cast <vmime::string>(u3)
+ );
// Test special characters
u3.getParams().clear();
u3.getParams()["&"] = "=";
- VASSERT_EQ("3.3", "proto://host/?%26=%3D",
- static_cast <vmime::string>(u3));
+ VASSERT_EQ(
+ "3.3",
+ "proto://host/?%26=%3D",
+ static_cast <vmime::string>(u3)
+ );
}
- void testUtilsEncode()
- {
+ void testUtilsEncode() {
+
VASSERT_EQ("1", "%01", vmime::utility::urlUtils::encode("\x01"));
VASSERT_EQ("2", "%20", vmime::utility::urlUtils::encode(" "));
VASSERT_EQ("3", "%FF", vmime::utility::urlUtils::encode("\xff"));
VASSERT_EQ("4", "a", vmime::utility::urlUtils::encode("a"));
}
- void testUtilsDecode()
- {
- for (int i = 0 ; i < 255 ; ++i)
- {
+ void testUtilsDecode() {
+
+ for (int i = 0 ; i < 255 ; ++i) {
+
std::ostringstream ossTest;
ossTest << "%" << "0123456789ABCDEF"[i / 16]
<< "0123456789ABCDEF"[i % 16];
@@ -247,22 +259,25 @@ VMIME_TEST_SUITE_BEGIN(urlTest)
vmime::string res;
res += static_cast <unsigned char>(i);
- VASSERT_EQ(ossNum.str(), res,
- vmime::utility::urlUtils::decode(ossTest.str()));
+ VASSERT_EQ(
+ ossNum.str(),
+ res,
+ vmime::utility::urlUtils::decode(ossTest.str())
+ );
}
}
- void testUtilsDecodeSpecialCases()
- {
+ void testUtilsDecodeSpecialCases() {
+
// Bug #1656547: segfault with '%' at the end of the string
VASSERT_EQ("1.1", "sadfsda%", vmime::utility::urlUtils::decode("sadfsda%"));
VASSERT_EQ("1.2", "sadfsda\x05", vmime::utility::urlUtils::decode("sadfsda%5"));
VASSERT_EQ("1.3", "sadfsda\x42", vmime::utility::urlUtils::decode("sadfsda%42"));
}
- void testUtilsEncodeReservedChars()
- {
+ void testUtilsEncodeReservedChars() {
+
VASSERT_EQ("1", "%24", vmime::utility::urlUtils::encode("$"));
VASSERT_EQ("2", "%26", vmime::utility::urlUtils::encode("&"));
VASSERT_EQ("3", "%2B", vmime::utility::urlUtils::encode("+"));
@@ -275,8 +290,8 @@ VMIME_TEST_SUITE_BEGIN(urlTest)
VASSERT_EQ("10", "%40", vmime::utility::urlUtils::encode("@"));
}
- void testUtilsEncodeUnsafeChars()
- {
+ void testUtilsEncodeUnsafeChars() {
+
VASSERT_EQ("1", "%20", vmime::utility::urlUtils::encode(" "));
VASSERT_EQ("2", "%22", vmime::utility::urlUtils::encode("\""));
VASSERT_EQ("3", "%3C", vmime::utility::urlUtils::encode("<"));
@@ -295,4 +310,3 @@ VMIME_TEST_SUITE_BEGIN(urlTest)
}
VMIME_TEST_SUITE_END
-