diff options
Diffstat (limited to 'tests/net/smtp')
-rw-r--r-- | tests/net/smtp/SMTPCommandSetTest.cpp | 28 | ||||
-rw-r--r-- | tests/net/smtp/SMTPCommandTest.cpp | 44 | ||||
-rw-r--r-- | tests/net/smtp/SMTPResponseTest.cpp | 70 | ||||
-rw-r--r-- | tests/net/smtp/SMTPTransportTest.cpp | 80 | ||||
-rw-r--r-- | tests/net/smtp/SMTPTransportTestUtils.hpp | 22 |
5 files changed, 112 insertions, 132 deletions
diff --git a/tests/net/smtp/SMTPCommandSetTest.cpp b/tests/net/smtp/SMTPCommandSetTest.cpp index 0cf4b03b..af250078 100644 --- a/tests/net/smtp/SMTPCommandSetTest.cpp +++ b/tests/net/smtp/SMTPCommandSetTest.cpp @@ -46,7 +46,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandSetTest) void testCreate() { - vmime::ref <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ false); + vmime::shared_ptr <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ false); VASSERT_NOT_NULL("Not null", cset); VASSERT_FALSE("Finished", cset->isFinished()); @@ -54,7 +54,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandSetTest) void testCreatePipeline() { - vmime::ref <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ true); + vmime::shared_ptr <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ true); VASSERT_NOT_NULL("Not null", cset); VASSERT_FALSE("Finished", cset->isFinished()); @@ -62,14 +62,14 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandSetTest) void testAddCommand() { - vmime::ref <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ false); + vmime::shared_ptr <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ false); VASSERT_NO_THROW("No throw 1", cset->addCommand(SMTPCommand::createCommand("MY_COMMAND1"))); VASSERT_EQ("Text", "MY_COMMAND1\r\n", cset->getText()); VASSERT_NO_THROW("No throw 2", cset->addCommand(SMTPCommand::createCommand("MY_COMMAND2"))); VASSERT_EQ("Text", "MY_COMMAND1\r\nMY_COMMAND2\r\n", cset->getText()); - vmime::ref <testSocket> sok = vmime::create <testSocket>(); + vmime::shared_ptr <testSocket> sok = vmime::make_shared <testSocket>(); cset->writeToSocket(sok); VASSERT_FALSE("Finished", cset->isFinished()); @@ -83,14 +83,14 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandSetTest) void testAddCommandPipeline() { - vmime::ref <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ true); + vmime::shared_ptr <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ true); VASSERT_NO_THROW("No throw 1", cset->addCommand(SMTPCommand::createCommand("MY_COMMAND1"))); VASSERT_EQ("Text", "MY_COMMAND1\r\n", cset->getText()); VASSERT_NO_THROW("No throw 2", cset->addCommand(SMTPCommand::createCommand("MY_COMMAND2"))); VASSERT_EQ("Text", "MY_COMMAND1\r\nMY_COMMAND2\r\n", cset->getText()); - vmime::ref <testSocket> sok = vmime::create <testSocket>(); + vmime::shared_ptr <testSocket> sok = vmime::make_shared <testSocket>(); vmime::string response; cset->writeToSocket(sok); @@ -105,12 +105,12 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandSetTest) void testWriteToSocket() { - vmime::ref <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ false); + vmime::shared_ptr <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ false); cset->addCommand(SMTPCommand::createCommand("MY_COMMAND1")); cset->addCommand(SMTPCommand::createCommand("MY_COMMAND2")); - vmime::ref <testSocket> sok = vmime::create <testSocket>(); + vmime::shared_ptr <testSocket> sok = vmime::make_shared <testSocket>(); vmime::string response; cset->writeToSocket(sok); @@ -126,12 +126,12 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandSetTest) void testWriteToSocketPipeline() { - vmime::ref <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ true); + vmime::shared_ptr <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ true); cset->addCommand(SMTPCommand::createCommand("MY_COMMAND1")); cset->addCommand(SMTPCommand::createCommand("MY_COMMAND2")); - vmime::ref <testSocket> sok = vmime::create <testSocket>(); + vmime::shared_ptr <testSocket> sok = vmime::make_shared <testSocket>(); vmime::string response; cset->writeToSocket(sok); @@ -142,12 +142,12 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandSetTest) void testGetLastCommandSent() { - vmime::ref <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ false); + vmime::shared_ptr <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ false); cset->addCommand(SMTPCommand::createCommand("MY_COMMAND1")); cset->addCommand(SMTPCommand::createCommand("MY_COMMAND2")); - vmime::ref <testSocket> sok = vmime::create <testSocket>(); + vmime::shared_ptr <testSocket> sok = vmime::make_shared <testSocket>(); cset->writeToSocket(sok); VASSERT_EQ("Cmd 1", "MY_COMMAND1", cset->getLastCommandSent()->getText()); @@ -158,12 +158,12 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandSetTest) void testGetLastCommandSentPipeline() { - vmime::ref <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ true); + vmime::shared_ptr <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ true); cset->addCommand(SMTPCommand::createCommand("MY_COMMAND1")); cset->addCommand(SMTPCommand::createCommand("MY_COMMAND2")); - vmime::ref <testSocket> sok = vmime::create <testSocket>(); + vmime::shared_ptr <testSocket> sok = vmime::make_shared <testSocket>(); cset->writeToSocket(sok); VASSERT_EQ("Cmd 1", "MY_COMMAND1", cset->getLastCommandSent()->getText()); diff --git a/tests/net/smtp/SMTPCommandTest.cpp b/tests/net/smtp/SMTPCommandTest.cpp index 9a2c90fc..6d466865 100644 --- a/tests/net/smtp/SMTPCommandTest.cpp +++ b/tests/net/smtp/SMTPCommandTest.cpp @@ -57,7 +57,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testCreateCommand() { - vmime::ref <SMTPCommand> cmd = SMTPCommand::createCommand("MY_COMMAND"); + vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::createCommand("MY_COMMAND"); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "MY_COMMAND", cmd->getText()); @@ -65,7 +65,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testCreateCommandParams() { - vmime::ref <SMTPCommand> cmd = SMTPCommand::createCommand("MY_COMMAND param1 param2"); + 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()); @@ -73,7 +73,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testHELO() { - vmime::ref <SMTPCommand> cmd = SMTPCommand::HELO("hostname"); + vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::HELO("hostname"); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "HELO hostname", cmd->getText()); @@ -81,7 +81,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testEHLO() { - vmime::ref <SMTPCommand> cmd = SMTPCommand::EHLO("hostname"); + vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::EHLO("hostname"); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "EHLO hostname", cmd->getText()); @@ -89,7 +89,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testAUTH() { - vmime::ref <SMTPCommand> cmd = SMTPCommand::AUTH("saslmechanism"); + vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::AUTH("saslmechanism"); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "AUTH saslmechanism", cmd->getText()); @@ -97,7 +97,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testSTARTTLS() { - vmime::ref <SMTPCommand> cmd = SMTPCommand::STARTTLS(); + vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::STARTTLS(); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "STARTTLS", cmd->getText()); @@ -105,7 +105,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testMAIL() { - vmime::ref <SMTPCommand> cmd = SMTPCommand::MAIL(vmime::mailbox("[email protected]"), false); + 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()); @@ -113,7 +113,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testMAIL_Encoded() { - vmime::ref <SMTPCommand> cmd = SMTPCommand::MAIL + vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::MAIL (vmime::mailbox(vmime::emailAddress("mailtest", "例え.テスト")), false); VASSERT_NOT_NULL("Not null", cmd); @@ -122,7 +122,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testMAIL_UTF8() { - vmime::ref <SMTPCommand> cmd = SMTPCommand::MAIL + vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::MAIL (vmime::mailbox(vmime::emailAddress("mailtest", "例え.テスト")), true); VASSERT_NOT_NULL("Not null", cmd); @@ -131,7 +131,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testMAIL_SIZE() { - vmime::ref <SMTPCommand> cmd = SMTPCommand::MAIL + vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::MAIL (vmime::mailbox("[email protected]"), false, 123456789); VASSERT_NOT_NULL("Not null", cmd); @@ -140,7 +140,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testMAIL_SIZE_UTF8() { - vmime::ref <SMTPCommand> cmd = SMTPCommand::MAIL + vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::MAIL (vmime::mailbox(vmime::emailAddress("mailtest", "例え.テスト")), true, 123456789); VASSERT_NOT_NULL("Not null", cmd); @@ -149,7 +149,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testRCPT() { - vmime::ref <SMTPCommand> cmd = SMTPCommand::RCPT(vmime::mailbox("[email protected]"), false); + 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()); @@ -157,7 +157,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testRCPT_Encoded() { - vmime::ref <SMTPCommand> cmd = SMTPCommand::RCPT + vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::RCPT (vmime::mailbox(vmime::emailAddress("mailtest", "例え.テスト")), false); VASSERT_NOT_NULL("Not null", cmd); @@ -166,7 +166,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testRCPT_UTF8() { - vmime::ref <SMTPCommand> cmd = SMTPCommand::RCPT + vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::RCPT (vmime::mailbox(vmime::emailAddress("mailtest", "例え.テスト")), true); VASSERT_NOT_NULL("Not null", cmd); @@ -175,7 +175,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testRSET() { - vmime::ref <SMTPCommand> cmd = SMTPCommand::RSET(); + vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::RSET(); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "RSET", cmd->getText()); @@ -183,7 +183,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testDATA() { - vmime::ref <SMTPCommand> cmd = SMTPCommand::DATA(); + vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::DATA(); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "DATA", cmd->getText()); @@ -191,12 +191,12 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testBDAT() { - vmime::ref <SMTPCommand> cmd1 = SMTPCommand::BDAT(12345, false); + vmime::shared_ptr <SMTPCommand> cmd1 = SMTPCommand::BDAT(12345, false); VASSERT_NOT_NULL("Not null", cmd1); VASSERT_EQ("Text", "BDAT 12345", cmd1->getText()); - vmime::ref <SMTPCommand> cmd2 = SMTPCommand::BDAT(67890, true); + vmime::shared_ptr <SMTPCommand> cmd2 = SMTPCommand::BDAT(67890, true); VASSERT_NOT_NULL("Not null", cmd2); VASSERT_EQ("Text", "BDAT 67890 LAST", cmd2->getText()); @@ -204,7 +204,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testNOOP() { - vmime::ref <SMTPCommand> cmd = SMTPCommand::NOOP(); + vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::NOOP(); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "NOOP", cmd->getText()); @@ -212,7 +212,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testQUIT() { - vmime::ref <SMTPCommand> cmd = SMTPCommand::QUIT(); + vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::QUIT(); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "QUIT", cmd->getText()); @@ -220,9 +220,9 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testWriteToSocket() { - vmime::ref <SMTPCommand> cmd = SMTPCommand::createCommand("MY_COMMAND param1 param2"); + vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::createCommand("MY_COMMAND param1 param2"); - vmime::ref <testSocket> sok = vmime::create <testSocket>(); + vmime::shared_ptr <testSocket> sok = vmime::make_shared <testSocket>(); cmd->writeToSocket(sok); vmime::string response; diff --git a/tests/net/smtp/SMTPResponseTest.cpp b/tests/net/smtp/SMTPResponseTest.cpp index 5e75b6a7..352f46c2 100644 --- a/tests/net/smtp/SMTPResponseTest.cpp +++ b/tests/net/smtp/SMTPResponseTest.cpp @@ -43,15 +43,15 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest) void testSingleLineResponse() { - 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>(); socket->localSend("123 Response Text\r\n"); vmime::net::smtp::SMTPResponse::state responseState; - vmime::ref <vmime::net::smtp::SMTPResponse> resp = + vmime::shared_ptr <vmime::net::smtp::SMTPResponse> resp = vmime::net::smtp::SMTPResponse::readResponse(socket, toh, responseState); VASSERT_EQ("Code", 123, resp->getCode()); @@ -61,15 +61,15 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest) 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>(); socket->localSend("123 Response Text\n"); vmime::net::smtp::SMTPResponse::state responseState; - vmime::ref <vmime::net::smtp::SMTPResponse> resp = + vmime::shared_ptr <vmime::net::smtp::SMTPResponse> resp = vmime::net::smtp::SMTPResponse::readResponse(socket, toh, responseState); VASSERT_EQ("Code", 123, resp->getCode()); @@ -79,9 +79,9 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest) 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>(); socket->localSend ( @@ -91,7 +91,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest) vmime::net::smtp::SMTPResponse::state responseState; - vmime::ref <vmime::net::smtp::SMTPResponse> resp = + vmime::shared_ptr <vmime::net::smtp::SMTPResponse> resp = vmime::net::smtp::SMTPResponse::readResponse(socket, toh, responseState); VASSERT_EQ("Code", 123, resp->getCode()); @@ -107,9 +107,9 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest) void testMultiLineResponseDifferentCode() { - 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>(); socket->localSend ( @@ -119,7 +119,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest) vmime::net::smtp::SMTPResponse::state responseState; - vmime::ref <vmime::net::smtp::SMTPResponse> resp = + vmime::shared_ptr <vmime::net::smtp::SMTPResponse> resp = vmime::net::smtp::SMTPResponse::readResponse(socket, toh, responseState); VASSERT_EQ("Code", 0, resp->getCode()); @@ -135,9 +135,9 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest) void testIncompleteMultiLineResponse() { - vmime::ref <testSocket> socket = vmime::create <testSocket>(); - vmime::ref <vmime::net::timeoutHandler> toh = - vmime::create <testTimeoutHandler>(1); + vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>(); + vmime::shared_ptr <vmime::net::timeoutHandler> toh = + vmime::make_shared <testTimeoutHandler>(1); socket->localSend ( @@ -155,9 +155,9 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest) void testNoResponseText() { - vmime::ref <testSocket> socket = vmime::create <testSocket>(); - vmime::ref <vmime::net::timeoutHandler> toh = - vmime::create <testTimeoutHandler>(1); + vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>(); + vmime::shared_ptr <vmime::net::timeoutHandler> toh = + vmime::make_shared <testTimeoutHandler>(1); socket->localSend ( @@ -166,7 +166,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest) vmime::net::smtp::SMTPResponse::state responseState; - vmime::ref <vmime::net::smtp::SMTPResponse> resp = + vmime::shared_ptr <vmime::net::smtp::SMTPResponse> resp = vmime::net::smtp::SMTPResponse::readResponse(socket, toh, responseState); VASSERT_EQ("Code", 250, resp->getCode()); @@ -176,15 +176,15 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest) void testEnhancedStatusCode() { - 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>(); socket->localSend("250 2.1.5 OK fu13sm4720601wic.7 - gsmtp\r\n"); vmime::net::smtp::SMTPResponse::state responseState; - vmime::ref <vmime::net::smtp::SMTPResponse> resp = + vmime::shared_ptr <vmime::net::smtp::SMTPResponse> resp = vmime::net::smtp::SMTPResponse::readResponse(socket, toh, responseState); VASSERT_EQ("Code", 250, resp->getCode()); @@ -197,15 +197,15 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest) void testNoEnhancedStatusCode() { - 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>(); socket->localSend("354 Go ahead fu13sm4720601wic.7 - gsmtp\r\n"); vmime::net::smtp::SMTPResponse::state responseState; - vmime::ref <vmime::net::smtp::SMTPResponse> resp = + vmime::shared_ptr <vmime::net::smtp::SMTPResponse> resp = vmime::net::smtp::SMTPResponse::readResponse(socket, toh, responseState); VASSERT_EQ("Code", 354, resp->getCode()); @@ -218,15 +218,15 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest) void testInvalidEnhancedStatusCode() { - 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>(); socket->localSend("250 4.2 xxx\r\n"); vmime::net::smtp::SMTPResponse::state responseState; - vmime::ref <vmime::net::smtp::SMTPResponse> resp = + vmime::shared_ptr <vmime::net::smtp::SMTPResponse> resp = vmime::net::smtp::SMTPResponse::readResponse(socket, toh, responseState); VASSERT_EQ("Code", 250, resp->getCode()); diff --git a/tests/net/smtp/SMTPTransportTest.cpp b/tests/net/smtp/SMTPTransportTest.cpp index 13c18309..5997588e 100644 --- a/tests/net/smtp/SMTPTransportTest.cpp +++ b/tests/net/smtp/SMTPTransportTest.cpp @@ -44,25 +44,25 @@ VMIME_TEST_SUITE_BEGIN(SMTPTransportTest) 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("smtp://invalid-smtp-server"); - vmime::ref <vmime::net::transport> store = sess->getTransport(url); + vmime::shared_ptr <vmime::net::transport> store = sess->getTransport(url); VASSERT_THROW("connect", store->connect(), vmime::exceptions::connection_error); } void testGreetingError() { - vmime::ref <vmime::net::session> session = - vmime::create <vmime::net::session>(); + vmime::shared_ptr <vmime::net::session> session = + vmime::make_shared <vmime::net::session>(); - vmime::ref <vmime::net::transport> tr = session->getTransport + vmime::shared_ptr <vmime::net::transport> tr = session->getTransport (vmime::utility::url("smtp://localhost")); - tr->setSocketFactory(vmime::create <testSocketFactory <greetingErrorSMTPTestSocket> >()); - tr->setTimeoutHandlerFactory(vmime::create <testTimeoutHandlerFactory>()); + tr->setSocketFactory(vmime::make_shared <testSocketFactory <greetingErrorSMTPTestSocket> >()); + tr->setTimeoutHandlerFactory(vmime::make_shared <testTimeoutHandlerFactory>()); VASSERT_THROW("Connection", tr->connect(), vmime::exceptions::connection_greeting_error); @@ -70,23 +70,23 @@ VMIME_TEST_SUITE_BEGIN(SMTPTransportTest) void testMAILandRCPT() { - vmime::ref <vmime::net::session> session = - vmime::create <vmime::net::session>(); + vmime::shared_ptr <vmime::net::session> session = + vmime::make_shared <vmime::net::session>(); - vmime::ref <vmime::net::transport> tr = session->getTransport + vmime::shared_ptr <vmime::net::transport> tr = session->getTransport (vmime::utility::url("smtp://localhost")); - tr->setSocketFactory(vmime::create <testSocketFactory <MAILandRCPTSMTPTestSocket> >()); - tr->setTimeoutHandlerFactory(vmime::create <testTimeoutHandlerFactory>()); + tr->setSocketFactory(vmime::make_shared <testSocketFactory <MAILandRCPTSMTPTestSocket> >()); + tr->setTimeoutHandlerFactory(vmime::make_shared <testTimeoutHandlerFactory>()); VASSERT_NO_THROW("Connection", tr->connect()); vmime::mailbox exp("[email protected]"); vmime::mailboxList recips; - recips.appendMailbox(vmime::create <vmime::mailbox>("[email protected]")); - recips.appendMailbox(vmime::create <vmime::mailbox>("[email protected]")); - recips.appendMailbox(vmime::create <vmime::mailbox>("[email protected]")); + recips.appendMailbox(vmime::make_shared <vmime::mailbox>("[email protected]")); + recips.appendMailbox(vmime::make_shared <vmime::mailbox>("[email protected]")); + recips.appendMailbox(vmime::make_shared <vmime::mailbox>("[email protected]")); vmime::string data("Message data"); vmime::utility::inputStreamStringAdapter is(data); @@ -96,52 +96,52 @@ VMIME_TEST_SUITE_BEGIN(SMTPTransportTest) void testChunking() { - vmime::ref <vmime::net::session> session = - vmime::create <vmime::net::session>(); + vmime::shared_ptr <vmime::net::session> session = + vmime::make_shared <vmime::net::session>(); - vmime::ref <vmime::net::transport> tr = session->getTransport + vmime::shared_ptr <vmime::net::transport> tr = session->getTransport (vmime::utility::url("smtp://localhost")); - tr->setSocketFactory(vmime::create <testSocketFactory <chunkingSMTPTestSocket> >()); - tr->setTimeoutHandlerFactory(vmime::create <testTimeoutHandlerFactory>()); + 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!", - tr.dynamicCast <vmime::net::smtp::SMTPTransport>()->getConnection()->hasExtension("CHUNKING")); + vmime::dynamicCast <vmime::net::smtp::SMTPTransport>(tr)->getConnection()->hasExtension("CHUNKING")); vmime::mailbox exp("[email protected]"); vmime::mailboxList recips; - recips.appendMailbox(vmime::create <vmime::mailbox>("[email protected]")); + recips.appendMailbox(vmime::make_shared <vmime::mailbox>("[email protected]")); - vmime::ref <vmime::message> msg = vmime::create <SMTPTestMessage>(); + vmime::shared_ptr <vmime::message> msg = vmime::make_shared <SMTPTestMessage>(); tr->send(msg, exp, recips); } void testSize_Chunking() { - vmime::ref <vmime::net::session> session = - vmime::create <vmime::net::session>(); + vmime::shared_ptr <vmime::net::session> session = + vmime::make_shared <vmime::net::session>(); - vmime::ref <vmime::net::transport> tr = session->getTransport + vmime::shared_ptr <vmime::net::transport> tr = session->getTransport (vmime::utility::url("smtp://localhost")); - tr->setSocketFactory(vmime::create <testSocketFactory <bigMessageSMTPTestSocket <true> > >()); - tr->setTimeoutHandlerFactory(vmime::create <testTimeoutHandlerFactory>()); + 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!", - tr.dynamicCast <vmime::net::smtp::SMTPTransport>()->getConnection()->hasExtension("SIZE")); + vmime::dynamicCast <vmime::net::smtp::SMTPTransport>(tr)->getConnection()->hasExtension("SIZE")); vmime::mailbox exp("[email protected]"); vmime::mailboxList recips; - recips.appendMailbox(vmime::create <vmime::mailbox>("[email protected]")); + recips.appendMailbox(vmime::make_shared <vmime::mailbox>("[email protected]")); - vmime::ref <vmime::message> msg = vmime::create <SMTPBigTestMessage4MB>(); + vmime::shared_ptr <vmime::message> msg = vmime::make_shared <SMTPBigTestMessage4MB>(); VASSERT_THROW("Connection", tr->send(msg, exp, recips), vmime::net::smtp::SMTPMessageSizeExceedsMaxLimitsException); @@ -149,26 +149,26 @@ VMIME_TEST_SUITE_BEGIN(SMTPTransportTest) void testSize_NoChunking() { - vmime::ref <vmime::net::session> session = - vmime::create <vmime::net::session>(); + vmime::shared_ptr <vmime::net::session> session = + vmime::make_shared <vmime::net::session>(); - vmime::ref <vmime::net::transport> tr = session->getTransport + vmime::shared_ptr <vmime::net::transport> tr = session->getTransport (vmime::utility::url("smtp://localhost")); - tr->setSocketFactory(vmime::create <testSocketFactory <bigMessageSMTPTestSocket <false> > >()); - tr->setTimeoutHandlerFactory(vmime::create <testTimeoutHandlerFactory>()); + 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!", - tr.dynamicCast <vmime::net::smtp::SMTPTransport>()->getConnection()->hasExtension("SIZE")); + vmime::dynamicCast <vmime::net::smtp::SMTPTransport>(tr)->getConnection()->hasExtension("SIZE")); vmime::mailbox exp("[email protected]"); vmime::mailboxList recips; - recips.appendMailbox(vmime::create <vmime::mailbox>("[email protected]")); + recips.appendMailbox(vmime::make_shared <vmime::mailbox>("[email protected]")); - vmime::ref <vmime::message> msg = vmime::create <SMTPBigTestMessage4MB>(); + vmime::shared_ptr <vmime::message> msg = vmime::make_shared <SMTPBigTestMessage4MB>(); VASSERT_THROW("Connection", tr->send(msg, exp, recips), vmime::net::smtp::SMTPMessageSizeExceedsMaxLimitsException); diff --git a/tests/net/smtp/SMTPTransportTestUtils.hpp b/tests/net/smtp/SMTPTransportTestUtils.hpp index b74f9783..dd7afeb5 100644 --- a/tests/net/smtp/SMTPTransportTestUtils.hpp +++ b/tests/net/smtp/SMTPTransportTestUtils.hpp @@ -410,7 +410,7 @@ public: vmime::utility::stream::size_type getChunkBufferSize() const { - static vmime::net::smtp::SMTPChunkingOutputStreamAdapter chunkStream(NULL); + static vmime::net::smtp::SMTPChunkingOutputStreamAdapter chunkStream(vmime::null); return chunkStream.getBlockSize(); } @@ -456,13 +456,11 @@ public: bigMessageSMTPTestSocket() { m_state = STATE_NOT_CONNECTED; - m_bdatChunkCount = 0; m_ehloSent = m_mailSent = m_rcptSent = m_quitSent = false; } ~bigMessageSMTPTestSocket() { - VASSERT_EQ("BDAT chunk count", 3, m_bdatChunkCount); VASSERT("Client must send the QUIT command", m_quitSent); } @@ -476,22 +474,6 @@ public: void onDataReceived() { - if (m_state == STATE_DATA) - { - if (m_bdatChunkReceived != m_bdatChunkSize) - { - const size_type remaining = m_bdatChunkSize - m_bdatChunkReceived; - const size_type received = localReceiveRaw(NULL, remaining); - - m_bdatChunkReceived += received; - } - - if (m_bdatChunkReceived == m_bdatChunkSize) - { - m_state = STATE_COMMAND; - } - } - processCommand(); } @@ -584,8 +566,6 @@ private: }; int m_state; - int m_bdatChunkCount; - int m_bdatChunkSize, m_bdatChunkReceived; bool m_ehloSent, m_mailSent, m_rcptSent, m_quitSent; }; |