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