aboutsummaryrefslogtreecommitdiffstats
path: root/tests/net/smtp/SMTPCommandTest.cpp
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2013-02-12 16:54:36 +0000
committerVincent Richard <[email protected]>2013-02-12 16:54:36 +0000
commitfeabba44702cf0720535b3af8e1d0ca89ae2b63d (patch)
tree110660060dd5080f5a3a77a50568024d0b88f699 /tests/net/smtp/SMTPCommandTest.cpp
parentRewrote SMTP command sending. Better code for pipelining. Report full command... (diff)
downloadvmime-feabba44702cf0720535b3af8e1d0ca89ae2b63d.tar.gz
vmime-feabba44702cf0720535b3af8e1d0ca89ae2b63d.zip
Unit tests for SMTPCommand and SMTPCommandSet. Fixed SMTPCommandSet::isFinished().
Diffstat (limited to '')
-rw-r--r--tests/net/smtp/SMTPCommandTest.cpp155
1 files changed, 155 insertions, 0 deletions
diff --git a/tests/net/smtp/SMTPCommandTest.cpp b/tests/net/smtp/SMTPCommandTest.cpp
new file mode 100644
index 00000000..93cdf7ae
--- /dev/null
+++ b/tests/net/smtp/SMTPCommandTest.cpp
@@ -0,0 +1,155 @@
+//
+// VMime library (http://www.vmime.org)
+// Copyright (C) 2002-2013 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
+// published by the Free Software Foundation; either version 3 of
+// the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// Linking this library statically or dynamically with other modules is making
+// a combined work based on this library. Thus, the terms and conditions of
+// the GNU General Public License cover the whole combination.
+//
+
+#include "tests/testUtils.hpp"
+
+#include "vmime/net/smtp/SMTPCommand.hpp"
+
+
+using namespace vmime::net::smtp;
+
+
+#define VMIME_TEST_SUITE SMTPCommandTest
+#define VMIME_TEST_SUITE_MODULE "Net/SMTP"
+
+
+VMIME_TEST_SUITE_BEGIN
+
+ VMIME_TEST_LIST_BEGIN
+ VMIME_TEST(testCreateCommand)
+ VMIME_TEST(testCreateCommandParams)
+ VMIME_TEST(testHELO)
+ VMIME_TEST(testEHLO)
+ VMIME_TEST(testAUTH)
+ VMIME_TEST(testSTARTTLS)
+ VMIME_TEST(testMAIL)
+ VMIME_TEST(testRCPT)
+ VMIME_TEST(testDATA)
+ VMIME_TEST(testNOOP)
+ VMIME_TEST(testQUIT)
+ VMIME_TEST(testWriteToSocket)
+ VMIME_TEST_LIST_END
+
+
+ void testCreateCommand()
+ {
+ vmime::ref <SMTPCommand> cmd = SMTPCommand::createCommand("MY_COMMAND");
+
+ VASSERT_NOT_NULL("Not null", cmd);
+ VASSERT_EQ("Text", "MY_COMMAND", cmd->getText());
+ }
+
+ void testCreateCommandParams()
+ {
+ vmime::ref <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()
+ {
+ vmime::ref <SMTPCommand> cmd = SMTPCommand::HELO("hostname");
+
+ VASSERT_NOT_NULL("Not null", cmd);
+ VASSERT_EQ("Text", "HELO hostname", cmd->getText());
+ }
+
+ void testEHLO()
+ {
+ vmime::ref <SMTPCommand> cmd = SMTPCommand::EHLO("hostname");
+
+ VASSERT_NOT_NULL("Not null", cmd);
+ VASSERT_EQ("Text", "EHLO hostname", cmd->getText());
+ }
+
+ void testAUTH()
+ {
+ vmime::ref <SMTPCommand> cmd = SMTPCommand::AUTH("saslmechanism");
+
+ VASSERT_NOT_NULL("Not null", cmd);
+ VASSERT_EQ("Text", "AUTH saslmechanism", cmd->getText());
+ }
+
+ void testSTARTTLS()
+ {
+ vmime::ref <SMTPCommand> cmd = SMTPCommand::STARTTLS();
+
+ VASSERT_NOT_NULL("Not null", cmd);
+ VASSERT_EQ("Text", "STARTTLS", cmd->getText());
+ }
+
+ void testMAIL()
+ {
+ vmime::ref <SMTPCommand> cmd = SMTPCommand::MAIL(vmime::mailbox("[email protected]"));
+
+ VASSERT_NOT_NULL("Not null", cmd);
+ VASSERT_EQ("Text", "MAIL FROM:<[email protected]>", cmd->getText());
+ }
+
+ void testRCPT()
+ {
+ vmime::ref <SMTPCommand> cmd = SMTPCommand::RCPT(vmime::mailbox("[email protected]"));
+
+ VASSERT_NOT_NULL("Not null", cmd);
+ VASSERT_EQ("Text", "RCPT TO:<[email protected]>", cmd->getText());
+ }
+
+ void testDATA()
+ {
+ vmime::ref <SMTPCommand> cmd = SMTPCommand::DATA();
+
+ VASSERT_NOT_NULL("Not null", cmd);
+ VASSERT_EQ("Text", "DATA", cmd->getText());
+ }
+
+ void testNOOP()
+ {
+ vmime::ref <SMTPCommand> cmd = SMTPCommand::NOOP();
+
+ VASSERT_NOT_NULL("Not null", cmd);
+ VASSERT_EQ("Text", "NOOP", cmd->getText());
+ }
+
+ void testQUIT()
+ {
+ vmime::ref <SMTPCommand> cmd = SMTPCommand::QUIT();
+
+ VASSERT_NOT_NULL("Not null", cmd);
+ VASSERT_EQ("Text", "QUIT", cmd->getText());
+ }
+
+ void testWriteToSocket()
+ {
+ vmime::ref <SMTPCommand> cmd = SMTPCommand::createCommand("MY_COMMAND param1 param2");
+
+ vmime::ref <testSocket> sok = vmime::create <testSocket>();
+ cmd->writeToSocket(sok);
+
+ vmime::string response;
+ sok->localReceive(response);
+
+ VASSERT_EQ("Sent buffer", "MY_COMMAND param1 param2\r\n", response);
+ }
+
+VMIME_TEST_SUITE_END