aboutsummaryrefslogtreecommitdiffstats
path: root/tests/net
diff options
context:
space:
mode:
Diffstat (limited to 'tests/net')
-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
18 files changed, 883 insertions, 832 deletions
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