comparison 3rdparty/vmime/tests/parser/messageIdSequenceTest.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
27 VMIME_TEST_SUITE_BEGIN(messageIdSequenceTest)
28
29 VMIME_TEST_LIST_BEGIN
30 VMIME_TEST(testParse)
31 VMIME_TEST(testGenerate)
32 VMIME_TEST_LIST_END
33
34
35 void testParse()
36 {
37 vmime::messageIdSequence s1;
38 s1.parse("");
39
40 VASSERT_EQ("1", 0, s1.getMessageIdCount());
41
42 vmime::messageIdSequence s2;
43 s2.parse(" \t ");
44
45 VASSERT_EQ("2", 0, s2.getMessageIdCount());
46
47 vmime::messageIdSequence s3;
48 s3.parse("<a@b>");
49
50 VASSERT_EQ("3.1", 1, s3.getMessageIdCount());
51 VASSERT_EQ("3.2", "a", s3.getMessageIdAt(0)->getLeft());
52 VASSERT_EQ("3.3", "b", s3.getMessageIdAt(0)->getRight());
53
54 vmime::messageIdSequence s4;
55 s4.parse("<a@b> \r\n\t<c@d>");
56
57 VASSERT_EQ("4.1", 2, s4.getMessageIdCount());
58 VASSERT_EQ("4.2", "a", s4.getMessageIdAt(0)->getLeft());
59 VASSERT_EQ("4.3", "b", s4.getMessageIdAt(0)->getRight());
60 VASSERT_EQ("4.4", "c", s4.getMessageIdAt(1)->getLeft());
61 VASSERT_EQ("4.5", "d", s4.getMessageIdAt(1)->getRight());
62 }
63
64 void testGenerate()
65 {
66 vmime::messageIdSequence s1;
67 s1.appendMessageId(vmime::make_shared <vmime::messageId>("a", "b"));
68
69 VASSERT_EQ("1", "<a@b>", s1.generate());
70
71 vmime::messageIdSequence s2;
72 s2.appendMessageId(vmime::make_shared <vmime::messageId>("a", "b"));
73 s2.appendMessageId(vmime::make_shared <vmime::messageId>("c", "d"));
74
75 VASSERT_EQ("2", "<a@b> <c@d>", s2.generate());
76 }
77
78 VMIME_TEST_SUITE_END
79