diff options
Diffstat (limited to 'tests/net/pop3')
-rw-r--r-- | tests/net/pop3/POP3CommandTest.cpp | 47 | ||||
-rw-r--r-- | tests/net/pop3/POP3ResponseTest.cpp | 80 | ||||
-rw-r--r-- | tests/net/pop3/POP3StoreTest.cpp | 14 | ||||
-rw-r--r-- | tests/net/pop3/POP3TestUtils.hpp | 15 | ||||
-rw-r--r-- | tests/net/pop3/POP3UtilsTest.cpp | 10 |
5 files changed, 84 insertions, 82 deletions
diff --git a/tests/net/pop3/POP3CommandTest.cpp b/tests/net/pop3/POP3CommandTest.cpp index 14c92be4..4733c96b 100644 --- a/tests/net/pop3/POP3CommandTest.cpp +++ b/tests/net/pop3/POP3CommandTest.cpp @@ -59,7 +59,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testCreateCommand() { - vmime::ref <POP3Command> cmd = POP3Command::createCommand("MY_COMMAND"); + vmime::shared_ptr <POP3Command> cmd = POP3Command::createCommand("MY_COMMAND"); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "MY_COMMAND", cmd->getText()); @@ -67,7 +67,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testCreateCommandParams() { - vmime::ref <POP3Command> cmd = POP3Command::createCommand("MY_COMMAND param1 param2"); + 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()); @@ -75,7 +75,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testCAPA() { - vmime::ref <POP3Command> cmd = POP3Command::CAPA(); + vmime::shared_ptr <POP3Command> cmd = POP3Command::CAPA(); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "CAPA", cmd->getText()); @@ -83,7 +83,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testNOOP() { - vmime::ref <POP3Command> cmd = POP3Command::NOOP(); + vmime::shared_ptr <POP3Command> cmd = POP3Command::NOOP(); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "NOOP", cmd->getText()); @@ -91,7 +91,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testAUTH() { - vmime::ref <POP3Command> cmd = POP3Command::AUTH("saslmechanism"); + vmime::shared_ptr <POP3Command> cmd = POP3Command::AUTH("saslmechanism"); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "AUTH saslmechanism", cmd->getText()); @@ -99,7 +99,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testSTLS() { - vmime::ref <POP3Command> cmd = POP3Command::STLS(); + vmime::shared_ptr <POP3Command> cmd = POP3Command::STLS(); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "STLS", cmd->getText()); @@ -107,7 +107,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testAPOP() { - vmime::ref <POP3Command> cmd = POP3Command::APOP("user", "digest"); + vmime::shared_ptr <POP3Command> cmd = POP3Command::APOP("user", "digest"); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "APOP user digest", cmd->getText()); @@ -115,7 +115,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testUSER() { - vmime::ref <POP3Command> cmd = POP3Command::USER("user"); + vmime::shared_ptr <POP3Command> cmd = POP3Command::USER("user"); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "USER user", cmd->getText()); @@ -123,7 +123,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testPASS() { - vmime::ref <POP3Command> cmd = POP3Command::PASS("pass"); + vmime::shared_ptr <POP3Command> cmd = POP3Command::PASS("pass"); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "PASS pass", cmd->getText()); @@ -131,7 +131,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testSTAT() { - vmime::ref <POP3Command> cmd = POP3Command::STAT(); + vmime::shared_ptr <POP3Command> cmd = POP3Command::STAT(); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "STAT", cmd->getText()); @@ -139,7 +139,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testLIST() { - vmime::ref <POP3Command> cmd = POP3Command::LIST(); + vmime::shared_ptr <POP3Command> cmd = POP3Command::LIST(); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "LIST", cmd->getText()); @@ -147,7 +147,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testLISTMessage() { - vmime::ref <POP3Command> cmd = POP3Command::LIST(42); + vmime::shared_ptr <POP3Command> cmd = POP3Command::LIST(42); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "LIST 42", cmd->getText()); @@ -155,7 +155,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testUIDL() { - vmime::ref <POP3Command> cmd = POP3Command::UIDL(); + vmime::shared_ptr <POP3Command> cmd = POP3Command::UIDL(); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "UIDL", cmd->getText()); @@ -163,7 +163,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testUIDLMessage() { - vmime::ref <POP3Command> cmd = POP3Command::UIDL(42); + vmime::shared_ptr <POP3Command> cmd = POP3Command::UIDL(42); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "UIDL 42", cmd->getText()); @@ -171,7 +171,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testDELE() { - vmime::ref <POP3Command> cmd = POP3Command::DELE(42); + vmime::shared_ptr <POP3Command> cmd = POP3Command::DELE(42); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "DELE 42", cmd->getText()); @@ -179,7 +179,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testRETR() { - vmime::ref <POP3Command> cmd = POP3Command::RETR(42); + vmime::shared_ptr <POP3Command> cmd = POP3Command::RETR(42); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "RETR 42", cmd->getText()); @@ -187,7 +187,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testTOP() { - vmime::ref <POP3Command> cmd = POP3Command::TOP(42, 567); + vmime::shared_ptr <POP3Command> cmd = POP3Command::TOP(42, 567); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "TOP 42 567", cmd->getText()); @@ -195,7 +195,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testRSET() { - vmime::ref <POP3Command> cmd = POP3Command::RSET(); + vmime::shared_ptr <POP3Command> cmd = POP3Command::RSET(); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "RSET", cmd->getText()); @@ -203,7 +203,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testQUIT() { - vmime::ref <POP3Command> cmd = POP3Command::QUIT(); + vmime::shared_ptr <POP3Command> cmd = POP3Command::QUIT(); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "QUIT", cmd->getText()); @@ -211,11 +211,12 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testWriteToSocket() { - vmime::ref <POP3Command> cmd = POP3Command::createCommand("MY_COMMAND param1 param2"); + vmime::shared_ptr <POP3Command> cmd = POP3Command::createCommand("MY_COMMAND param1 param2"); - vmime::ref <testSocket> sok = vmime::create <testSocket>(); - vmime::ref <POP3ConnectionTest> conn = vmime::create <POP3ConnectionTest> - (sok.dynamicCast <vmime::net::socket>(), vmime::null); + 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>()); cmd->send(conn); diff --git a/tests/net/pop3/POP3ResponseTest.cpp b/tests/net/pop3/POP3ResponseTest.cpp index f1fbcd54..2d3b3d32 100644 --- a/tests/net/pop3/POP3ResponseTest.cpp +++ b/tests/net/pop3/POP3ResponseTest.cpp @@ -47,15 +47,15 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest) void testSingleLineResponseOK() { - vmime::ref <testSocket> socket = vmime::create <testSocket>(); - vmime::ref <vmime::net::timeoutHandler> toh = vmime::create <testTimeoutHandler>(); + vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>(); + vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>(); - vmime::ref <POP3ConnectionTest> conn = vmime::create <POP3ConnectionTest> - (socket.dynamicCast <vmime::net::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"); - vmime::ref <POP3Response> resp = + vmime::shared_ptr <POP3Response> resp = POP3Response::readResponse(conn); VASSERT_EQ("Code", POP3Response::CODE_OK, resp->getCode()); @@ -67,15 +67,15 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest) void testSingleLineResponseERR() { - vmime::ref <testSocket> socket = vmime::create <testSocket>(); - vmime::ref <vmime::net::timeoutHandler> toh = vmime::create <testTimeoutHandler>(); + vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>(); + vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>(); - vmime::ref <POP3ConnectionTest> conn = vmime::create <POP3ConnectionTest> - (socket.dynamicCast <vmime::net::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"); - vmime::ref <POP3Response> resp = + vmime::shared_ptr <POP3Response> resp = POP3Response::readResponse(conn); VASSERT_EQ("Code", POP3Response::CODE_ERR, resp->getCode()); @@ -87,15 +87,15 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest) void testSingleLineResponseReady() { - vmime::ref <testSocket> socket = vmime::create <testSocket>(); - vmime::ref <vmime::net::timeoutHandler> toh = vmime::create <testTimeoutHandler>(); + vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>(); + vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>(); - vmime::ref <POP3ConnectionTest> conn = vmime::create <POP3ConnectionTest> - (socket.dynamicCast <vmime::net::socket>(), toh); + vmime::shared_ptr <POP3ConnectionTest> conn = vmime::make_shared <POP3ConnectionTest> + (vmime::dynamicCast <vmime::net::socket>(socket), toh); socket->localSend("+ challenge_string\r\n"); - vmime::ref <POP3Response> resp = + vmime::shared_ptr <POP3Response> resp = POP3Response::readResponse(conn); VASSERT_EQ("Code", POP3Response::CODE_READY, resp->getCode()); @@ -107,15 +107,15 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest) void testSingleLineResponseInvalid() { - vmime::ref <testSocket> socket = vmime::create <testSocket>(); - vmime::ref <vmime::net::timeoutHandler> toh = vmime::create <testTimeoutHandler>(); + vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>(); + vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>(); - vmime::ref <POP3ConnectionTest> conn = vmime::create <POP3ConnectionTest> - (socket.dynamicCast <vmime::net::socket>(), toh); + vmime::shared_ptr <POP3ConnectionTest> conn = vmime::make_shared <POP3ConnectionTest> + (vmime::dynamicCast <vmime::net::socket>(socket), toh); socket->localSend("Invalid Response Text\r\n"); - vmime::ref <POP3Response> resp = + vmime::shared_ptr <POP3Response> resp = POP3Response::readResponse(conn); VASSERT_EQ("Code", POP3Response::CODE_ERR, resp->getCode()); @@ -127,15 +127,15 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest) void testSingleLineResponseLF() { - vmime::ref <testSocket> socket = vmime::create <testSocket>(); - vmime::ref <vmime::net::timeoutHandler> toh = vmime::create <testTimeoutHandler>(); + vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>(); + vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>(); - vmime::ref <POP3ConnectionTest> conn = vmime::create <POP3ConnectionTest> - (socket.dynamicCast <vmime::net::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"); - vmime::ref <POP3Response> resp = + vmime::shared_ptr <POP3Response> resp = POP3Response::readResponse(conn); VASSERT_EQ("Code", POP3Response::CODE_OK, resp->getCode()); @@ -147,18 +147,18 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest) void testMultiLineResponse() { - vmime::ref <testSocket> socket = vmime::create <testSocket>(); - vmime::ref <vmime::net::timeoutHandler> toh = vmime::create <testTimeoutHandler>(); + vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>(); + vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>(); - vmime::ref <POP3ConnectionTest> conn = vmime::create <POP3ConnectionTest> - (socket.dynamicCast <vmime::net::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"); socket->localSend("Line 2\r\n"); socket->localSend(".\r\n"); - vmime::ref <POP3Response> resp = + vmime::shared_ptr <POP3Response> resp = POP3Response::readMultilineResponse(conn); VASSERT_EQ("Code", POP3Response::CODE_OK, resp->getCode()); @@ -172,18 +172,18 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest) void testMultiLineResponseLF() { - vmime::ref <testSocket> socket = vmime::create <testSocket>(); - vmime::ref <vmime::net::timeoutHandler> toh = vmime::create <testTimeoutHandler>(); + vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>(); + vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>(); - vmime::ref <POP3ConnectionTest> conn = vmime::create <POP3ConnectionTest> - (socket.dynamicCast <vmime::net::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"); socket->localSend("Line 2\n"); socket->localSend(".\n"); - vmime::ref <POP3Response> resp = + vmime::shared_ptr <POP3Response> resp = POP3Response::readMultilineResponse(conn); VASSERT_EQ("Code", POP3Response::CODE_OK, resp->getCode()); @@ -202,11 +202,11 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest) for (unsigned int i = 0 ; i < 5000 ; ++i) data << "VMIME.VMIME\nVMIME\r\nVMIME_VMIME"; - vmime::ref <testSocket> socket = vmime::create <testSocket>(); - vmime::ref <vmime::net::timeoutHandler> toh = vmime::create <testTimeoutHandler>(); + vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>(); + vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>(); - vmime::ref <POP3ConnectionTest> conn = vmime::create <POP3ConnectionTest> - (socket.dynamicCast <vmime::net::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()); @@ -215,7 +215,7 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest) vmime::string receivedData; vmime::utility::outputStreamStringAdapter receivedDataStream(receivedData); - vmime::ref <POP3Response> resp = + vmime::shared_ptr <POP3Response> resp = POP3Response::readLargeResponse(conn, receivedDataStream, NULL, 0); VASSERT_EQ("Code", POP3Response::CODE_OK, resp->getCode()); diff --git a/tests/net/pop3/POP3StoreTest.cpp b/tests/net/pop3/POP3StoreTest.cpp index d938f472..5517f770 100644 --- a/tests/net/pop3/POP3StoreTest.cpp +++ b/tests/net/pop3/POP3StoreTest.cpp @@ -39,29 +39,29 @@ VMIME_TEST_SUITE_BEGIN(POP3StoreTest) void testCreateFromURL() { - vmime::ref <vmime::net::session> sess - = vmime::create <vmime::net::session>(); + vmime::shared_ptr <vmime::net::session> sess + = vmime::make_shared <vmime::net::session>(); // POP3 vmime::utility::url url("pop3://pop3.vmime.org"); - vmime::ref <vmime::net::store> store = sess->getStore(url); + vmime::shared_ptr <vmime::net::store> store = sess->getStore(url); VASSERT_TRUE("pop3", typeid(*store) == typeid(vmime::net::pop3::POP3Store)); // POP3S vmime::utility::url url2("pop3s://pop3s.vmime.org"); - vmime::ref <vmime::net::store> store2 = sess->getStore(url2); + vmime::shared_ptr <vmime::net::store> store2 = sess->getStore(url2); VASSERT_TRUE("pop3s", typeid(*store2) == typeid(vmime::net::pop3::POP3SStore)); } void testConnectToInvalidServer() { - vmime::ref <vmime::net::session> sess - = vmime::create <vmime::net::session>(); + vmime::shared_ptr <vmime::net::session> sess + = vmime::make_shared <vmime::net::session>(); vmime::utility::url url("pop3://invalid-pop3-server"); - vmime::ref <vmime::net::store> store = sess->getStore(url); + vmime::shared_ptr <vmime::net::store> store = sess->getStore(url); VASSERT_THROW("connect", store->connect(), vmime::exceptions::connection_error); } diff --git a/tests/net/pop3/POP3TestUtils.hpp b/tests/net/pop3/POP3TestUtils.hpp index 26b6601a..1c6e8935 100644 --- a/tests/net/pop3/POP3TestUtils.hpp +++ b/tests/net/pop3/POP3TestUtils.hpp @@ -29,25 +29,26 @@ class POP3ConnectionTest : public vmime::net::pop3::POP3Connection { public: - POP3ConnectionTest(vmime::ref <vmime::net::socket> socket, - vmime::ref <vmime::net::timeoutHandler> timeoutHandler) - : POP3Connection(NULL, NULL), + POP3ConnectionTest(vmime::shared_ptr <vmime::net::socket> socket, + vmime::shared_ptr <vmime::net::timeoutHandler> timeoutHandler) + : POP3Connection(vmime::shared_ptr <vmime::net::pop3::POP3Store>(), + vmime::shared_ptr <vmime::security::authenticator>()), m_socket(socket), m_timeoutHandler(timeoutHandler) { } - vmime::ref <vmime::net::socket> getSocket() + vmime::shared_ptr <vmime::net::socket> getSocket() { return m_socket; } - vmime::ref <vmime::net::timeoutHandler> getTimeoutHandler() + vmime::shared_ptr <vmime::net::timeoutHandler> getTimeoutHandler() { return m_timeoutHandler; } private: - vmime::ref <vmime::net::socket> m_socket; - vmime::ref <vmime::net::timeoutHandler> m_timeoutHandler; + vmime::shared_ptr <vmime::net::socket> m_socket; + vmime::shared_ptr <vmime::net::timeoutHandler> m_timeoutHandler; }; diff --git a/tests/net/pop3/POP3UtilsTest.cpp b/tests/net/pop3/POP3UtilsTest.cpp index 9d443ddb..55a99806 100644 --- a/tests/net/pop3/POP3UtilsTest.cpp +++ b/tests/net/pop3/POP3UtilsTest.cpp @@ -41,11 +41,11 @@ VMIME_TEST_SUITE_BEGIN(POP3UtilsTest) void testParseMultiListOrUidlResponse() { - vmime::ref <testSocket> socket = vmime::create <testSocket>(); - vmime::ref <vmime::net::timeoutHandler> toh = vmime::create <testTimeoutHandler>(); + vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>(); + vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>(); - vmime::ref <POP3ConnectionTest> conn = vmime::create <POP3ConnectionTest> - (socket.dynamicCast <vmime::net::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"); @@ -55,7 +55,7 @@ VMIME_TEST_SUITE_BEGIN(POP3UtilsTest) socket->localSend("8 yz \r\n"); socket->localSend(".\r\n"); - vmime::ref <POP3Response> resp = + vmime::shared_ptr <POP3Response> resp = POP3Response::readMultilineResponse(conn); std::map <int, vmime::string> result; |