Mercurial > thymian
comparison 3rdparty/vmime/tests/net/pop3/POP3UtilsTest.cpp @ 0:a4671277546c tip
created the repository for the thymian project
| author | ferencd |
|---|---|
| date | Tue, 17 Aug 2021 11:19:54 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:a4671277546c |
|---|---|
| 1 // | |
| 2 // VMime library (http://www.vmime.org) | |
| 3 // Copyright (C) 2002-2013 Vincent Richard <vincent@vmime.org> | |
| 4 // | |
| 5 // This program is free software; you can redistribute it and/or | |
| 6 // modify it under the terms of the GNU General Public License as | |
| 7 // published by the Free Software Foundation; either version 3 of | |
| 8 // the License, or (at your option) any later version. | |
| 9 // | |
| 10 // This program is distributed in the hope that it will be useful, | |
| 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 // General Public License for more details. | |
| 14 // | |
| 15 // You should have received a copy of the GNU General Public License along | |
| 16 // with this program; if not, write to the Free Software Foundation, Inc., | |
| 17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 18 // | |
| 19 // Linking this library statically or dynamically with other modules is making | |
| 20 // a combined work based on this library. Thus, the terms and conditions of | |
| 21 // the GNU General Public License cover the whole combination. | |
| 22 // | |
| 23 | |
| 24 #include "tests/testUtils.hpp" | |
| 25 | |
| 26 #include "tests/net/pop3/POP3TestUtils.hpp" | |
| 27 | |
| 28 #include "vmime/net/pop3/POP3Utils.hpp" | |
| 29 #include "vmime/net/pop3/POP3Response.hpp" | |
| 30 | |
| 31 | |
| 32 using namespace vmime::net::pop3; | |
| 33 | |
| 34 | |
| 35 VMIME_TEST_SUITE_BEGIN(POP3UtilsTest) | |
| 36 | |
| 37 VMIME_TEST_LIST_BEGIN | |
| 38 VMIME_TEST(testParseMultiListOrUidlResponse) | |
| 39 VMIME_TEST_LIST_END | |
| 40 | |
| 41 | |
| 42 void testParseMultiListOrUidlResponse() | |
| 43 { | |
| 44 vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>(); | |
| 45 vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>(); | |
| 46 | |
| 47 vmime::shared_ptr <POP3ConnectionTest> conn = vmime::make_shared <POP3ConnectionTest> | |
| 48 (vmime::dynamicCast <vmime::net::socket>(socket), toh); | |
| 49 | |
| 50 socket->localSend("+OK Response Text\r\n"); | |
| 51 socket->localSend("1 abcdef\r\n"); | |
| 52 socket->localSend("23 ghijkl\r\n"); | |
| 53 socket->localSend("4\tmnopqr\r\n"); | |
| 54 socket->localSend("567xx\tstuvwx\r\n"); | |
| 55 socket->localSend("8 yz \r\n"); | |
| 56 socket->localSend(".\r\n"); | |
| 57 | |
| 58 vmime::shared_ptr <POP3Response> resp = | |
| 59 POP3Response::readMultilineResponse(conn); | |
| 60 | |
| 61 std::map <int, vmime::string> result; | |
| 62 POP3Utils::parseMultiListOrUidlResponse(resp, result); | |
| 63 | |
| 64 VASSERT_EQ("Count", 5, result.size()); | |
| 65 VASSERT_EQ("1", "abcdef", result[1]); | |
| 66 VASSERT_EQ("2 (multiple spaces)", "ghijkl", result[23]); | |
| 67 VASSERT_EQ("3 (with tab)", "mnopqr", result[4]); | |
| 68 VASSERT_EQ("4 (with invalid digit)", "stuvwx", result[567]); | |
| 69 VASSERT_EQ("5 (with extra space)", "yz", result[8]); | |
| 70 } | |
| 71 | |
| 72 VMIME_TEST_SUITE_END | |
| 73 |
