comparison 3rdparty/vmime/tests/misc/importanceHelperTest.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 "vmime/misc/importanceHelper.hpp"
27
28
29 VMIME_TEST_SUITE_BEGIN(importanceHelperTest)
30
31 VMIME_TEST_LIST_BEGIN
32 VMIME_TEST(testResetImportance)
33
34 VMIME_TEST(testSetImportance1)
35 VMIME_TEST(testSetImportance2)
36 VMIME_TEST(testSetImportance3)
37 VMIME_TEST(testSetImportance4)
38 VMIME_TEST(testSetImportance5)
39
40 VMIME_TEST(testGetImportance1)
41 VMIME_TEST(testGetImportance2)
42 VMIME_TEST(testGetImportance3)
43 VMIME_TEST(testGetImportance4)
44 VMIME_TEST(testGetImportance5)
45 VMIME_TEST_LIST_END
46
47
48 // resetImportance
49
50 void testResetImportance()
51 {
52 vmime::shared_ptr <vmime::header> hdr = vmime::make_shared <vmime::header>();
53
54 hdr->getField("Importance")->setValue("xxx");
55 hdr->getField("X-Priority")->setValue("yyy");
56
57 VASSERT_NO_THROW("1", hdr->findField("Importance"));
58 VASSERT_NO_THROW("2", hdr->findField("X-Priority"));
59
60 vmime::misc::importanceHelper::resetImportanceHeader(hdr);
61
62 VASSERT_NULL("3", hdr->findField("Importance"));
63 VASSERT_NULL("4", hdr->findField("X-Priority"));
64 }
65
66
67 // setImportance
68
69 void testSetImportanceImpl(const vmime::misc::importanceHelper::Importance i,
70 const std::string& ImportanceValue, const std::string& XPriorityValue)
71 {
72 vmime::shared_ptr <vmime::header> hdr = vmime::make_shared <vmime::header>();
73
74 vmime::misc::importanceHelper::setImportanceHeader(hdr, i);
75
76 VASSERT_NO_THROW("1", hdr->findField("Importance"));
77 VASSERT_EQ("2", ImportanceValue, hdr->findField("Importance")->getValue()->generate());
78
79 VASSERT_NO_THROW("3", hdr->findField("X-Priority"));
80 VASSERT_EQ("4", XPriorityValue, hdr->findField("X-Priority")->getValue()->generate());
81 }
82
83 void testSetImportance1()
84 {
85 testSetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_HIGHEST,
86 "high", "1 (Highest)");
87 }
88
89 void testSetImportance2()
90 {
91 testSetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_HIGH,
92 "high", "2 (High)");
93 }
94
95 void testSetImportance3()
96 {
97 testSetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_NORMAL,
98 "normal", "3 (Normal)");
99 }
100
101 void testSetImportance4()
102 {
103 testSetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_LOW,
104 "low", "4 (Low)");
105 }
106
107 void testSetImportance5()
108 {
109 testSetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_LOWEST,
110 "low", "5 (Lowest)");
111 }
112
113
114 // getImportance
115
116 void testGetImportanceImpl(const vmime::misc::importanceHelper::Importance i1,
117 const vmime::misc::importanceHelper::Importance i2,
118 const std::string& ImportanceValue, const std::string& XPriorityValue)
119 {
120 vmime::shared_ptr <vmime::header> hdr1 = vmime::make_shared <vmime::header>();
121
122 hdr1->getField("Importance")->setValue(ImportanceValue);
123 VASSERT_EQ("1", i1, vmime::misc::importanceHelper::getImportanceHeader(hdr1));
124
125 vmime::shared_ptr <vmime::header> hdr2 = vmime::make_shared <vmime::header>();
126
127 hdr2->getField("X-Priority")->setValue(XPriorityValue);
128 VASSERT_EQ("2", i2, vmime::misc::importanceHelper::getImportanceHeader(hdr2));
129 }
130
131 void testGetImportance1()
132 {
133 testGetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_HIGHEST,
134 vmime::misc::importanceHelper::IMPORTANCE_HIGHEST, "high", "1 (Highest)");
135 }
136
137 void testGetImportance2()
138 {
139 testGetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_HIGHEST,
140 vmime::misc::importanceHelper::IMPORTANCE_HIGH, "high", "2 (High)");
141 }
142
143 void testGetImportance3()
144 {
145 testGetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_NORMAL,
146 vmime::misc::importanceHelper::IMPORTANCE_NORMAL, "normal", "3 (Normal)");
147 }
148
149 void testGetImportance4()
150 {
151 testGetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_LOWEST,
152 vmime::misc::importanceHelper::IMPORTANCE_LOW, "low", "4 (Low)");
153 }
154
155 void testGetImportance5()
156 {
157 testGetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_LOWEST,
158 vmime::misc::importanceHelper::IMPORTANCE_LOWEST, "low", "5 (Lowest)");
159 }
160
161 VMIME_TEST_SUITE_END
162