comparison 3rdparty/vmime/tests/net/pop3/POP3StoreTest.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/POP3Store.hpp"
29 #include "vmime/net/pop3/POP3SStore.hpp"
30
31
32 VMIME_TEST_SUITE_BEGIN(POP3StoreTest)
33
34 VMIME_TEST_LIST_BEGIN
35 VMIME_TEST(testCreateFromURL)
36 VMIME_TEST(testConnectToInvalidServer)
37 VMIME_TEST_LIST_END
38
39
40 void testCreateFromURL()
41 {
42 vmime::shared_ptr <vmime::net::session> sess
43 = vmime::make_shared <vmime::net::session>();
44
45 // POP3
46 vmime::utility::url url("pop3://pop3.vmime.org");
47 vmime::shared_ptr <vmime::net::store> store = sess->getStore(url);
48
49 VASSERT_TRUE("pop3", typeid(*store) == typeid(vmime::net::pop3::POP3Store));
50
51 // POP3S
52 vmime::utility::url url2("pop3s://pop3s.vmime.org");
53 vmime::shared_ptr <vmime::net::store> store2 = sess->getStore(url2);
54
55 VASSERT_TRUE("pop3s", typeid(*store2) == typeid(vmime::net::pop3::POP3SStore));
56 }
57
58 void testConnectToInvalidServer()
59 {
60 vmime::shared_ptr <vmime::net::session> sess
61 = vmime::make_shared <vmime::net::session>();
62
63 vmime::utility::url url("pop3://invalid-pop3-server");
64 vmime::shared_ptr <vmime::net::store> store = sess->getStore(url);
65
66 VASSERT_THROW("connect", store->connect(), vmime::exceptions::connection_error);
67 }
68
69 VMIME_TEST_SUITE_END