ferencd@0: // ferencd@0: // VMime library (http://www.vmime.org) ferencd@0: // Copyright (C) 2002-2013 Vincent Richard ferencd@0: // ferencd@0: // This program is free software; you can redistribute it and/or ferencd@0: // modify it under the terms of the GNU General Public License as ferencd@0: // published by the Free Software Foundation; either version 3 of ferencd@0: // the License, or (at your option) any later version. ferencd@0: // ferencd@0: // This program is distributed in the hope that it will be useful, ferencd@0: // but WITHOUT ANY WARRANTY; without even the implied warranty of ferencd@0: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ferencd@0: // General Public License for more details. ferencd@0: // ferencd@0: // You should have received a copy of the GNU General Public License along ferencd@0: // with this program; if not, write to the Free Software Foundation, Inc., ferencd@0: // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ferencd@0: // ferencd@0: // Linking this library statically or dynamically with other modules is making ferencd@0: // a combined work based on this library. Thus, the terms and conditions of ferencd@0: // the GNU General Public License cover the whole combination. ferencd@0: // ferencd@0: ferencd@0: #include "tests/testUtils.hpp" ferencd@0: ferencd@0: #include "tests/net/pop3/POP3TestUtils.hpp" ferencd@0: ferencd@0: #include "vmime/net/pop3/POP3Utils.hpp" ferencd@0: #include "vmime/net/pop3/POP3Response.hpp" ferencd@0: ferencd@0: ferencd@0: using namespace vmime::net::pop3; ferencd@0: ferencd@0: ferencd@0: VMIME_TEST_SUITE_BEGIN(POP3UtilsTest) ferencd@0: ferencd@0: VMIME_TEST_LIST_BEGIN ferencd@0: VMIME_TEST(testParseMultiListOrUidlResponse) ferencd@0: VMIME_TEST_LIST_END ferencd@0: ferencd@0: ferencd@0: void testParseMultiListOrUidlResponse() ferencd@0: { ferencd@0: vmime::shared_ptr socket = vmime::make_shared (); ferencd@0: vmime::shared_ptr toh = vmime::make_shared (); ferencd@0: ferencd@0: vmime::shared_ptr conn = vmime::make_shared ferencd@0: (vmime::dynamicCast (socket), toh); ferencd@0: ferencd@0: socket->localSend("+OK Response Text\r\n"); ferencd@0: socket->localSend("1 abcdef\r\n"); ferencd@0: socket->localSend("23 ghijkl\r\n"); ferencd@0: socket->localSend("4\tmnopqr\r\n"); ferencd@0: socket->localSend("567xx\tstuvwx\r\n"); ferencd@0: socket->localSend("8 yz \r\n"); ferencd@0: socket->localSend(".\r\n"); ferencd@0: ferencd@0: vmime::shared_ptr resp = ferencd@0: POP3Response::readMultilineResponse(conn); ferencd@0: ferencd@0: std::map result; ferencd@0: POP3Utils::parseMultiListOrUidlResponse(resp, result); ferencd@0: ferencd@0: VASSERT_EQ("Count", 5, result.size()); ferencd@0: VASSERT_EQ("1", "abcdef", result[1]); ferencd@0: VASSERT_EQ("2 (multiple spaces)", "ghijkl", result[23]); ferencd@0: VASSERT_EQ("3 (with tab)", "mnopqr", result[4]); ferencd@0: VASSERT_EQ("4 (with invalid digit)", "stuvwx", result[567]); ferencd@0: VASSERT_EQ("5 (with extra space)", "yz", result[8]); ferencd@0: } ferencd@0: ferencd@0: VMIME_TEST_SUITE_END ferencd@0: