annotate 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
rev   line source
ferencd@0 1 //
ferencd@0 2 // VMime library (http://www.vmime.org)
ferencd@0 3 // Copyright (C) 2002-2013 Vincent Richard <vincent@vmime.org>
ferencd@0 4 //
ferencd@0 5 // This program is free software; you can redistribute it and/or
ferencd@0 6 // modify it under the terms of the GNU General Public License as
ferencd@0 7 // published by the Free Software Foundation; either version 3 of
ferencd@0 8 // the License, or (at your option) any later version.
ferencd@0 9 //
ferencd@0 10 // This program is distributed in the hope that it will be useful,
ferencd@0 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
ferencd@0 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
ferencd@0 13 // General Public License for more details.
ferencd@0 14 //
ferencd@0 15 // You should have received a copy of the GNU General Public License along
ferencd@0 16 // with this program; if not, write to the Free Software Foundation, Inc.,
ferencd@0 17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
ferencd@0 18 //
ferencd@0 19 // Linking this library statically or dynamically with other modules is making
ferencd@0 20 // a combined work based on this library. Thus, the terms and conditions of
ferencd@0 21 // the GNU General Public License cover the whole combination.
ferencd@0 22 //
ferencd@0 23
ferencd@0 24 #include "tests/testUtils.hpp"
ferencd@0 25
ferencd@0 26 #include "vmime/misc/importanceHelper.hpp"
ferencd@0 27
ferencd@0 28
ferencd@0 29 VMIME_TEST_SUITE_BEGIN(importanceHelperTest)
ferencd@0 30
ferencd@0 31 VMIME_TEST_LIST_BEGIN
ferencd@0 32 VMIME_TEST(testResetImportance)
ferencd@0 33
ferencd@0 34 VMIME_TEST(testSetImportance1)
ferencd@0 35 VMIME_TEST(testSetImportance2)
ferencd@0 36 VMIME_TEST(testSetImportance3)
ferencd@0 37 VMIME_TEST(testSetImportance4)
ferencd@0 38 VMIME_TEST(testSetImportance5)
ferencd@0 39
ferencd@0 40 VMIME_TEST(testGetImportance1)
ferencd@0 41 VMIME_TEST(testGetImportance2)
ferencd@0 42 VMIME_TEST(testGetImportance3)
ferencd@0 43 VMIME_TEST(testGetImportance4)
ferencd@0 44 VMIME_TEST(testGetImportance5)
ferencd@0 45 VMIME_TEST_LIST_END
ferencd@0 46
ferencd@0 47
ferencd@0 48 // resetImportance
ferencd@0 49
ferencd@0 50 void testResetImportance()
ferencd@0 51 {
ferencd@0 52 vmime::shared_ptr <vmime::header> hdr = vmime::make_shared <vmime::header>();
ferencd@0 53
ferencd@0 54 hdr->getField("Importance")->setValue("xxx");
ferencd@0 55 hdr->getField("X-Priority")->setValue("yyy");
ferencd@0 56
ferencd@0 57 VASSERT_NO_THROW("1", hdr->findField("Importance"));
ferencd@0 58 VASSERT_NO_THROW("2", hdr->findField("X-Priority"));
ferencd@0 59
ferencd@0 60 vmime::misc::importanceHelper::resetImportanceHeader(hdr);
ferencd@0 61
ferencd@0 62 VASSERT_NULL("3", hdr->findField("Importance"));
ferencd@0 63 VASSERT_NULL("4", hdr->findField("X-Priority"));
ferencd@0 64 }
ferencd@0 65
ferencd@0 66
ferencd@0 67 // setImportance
ferencd@0 68
ferencd@0 69 void testSetImportanceImpl(const vmime::misc::importanceHelper::Importance i,
ferencd@0 70 const std::string& ImportanceValue, const std::string& XPriorityValue)
ferencd@0 71 {
ferencd@0 72 vmime::shared_ptr <vmime::header> hdr = vmime::make_shared <vmime::header>();
ferencd@0 73
ferencd@0 74 vmime::misc::importanceHelper::setImportanceHeader(hdr, i);
ferencd@0 75
ferencd@0 76 VASSERT_NO_THROW("1", hdr->findField("Importance"));
ferencd@0 77 VASSERT_EQ("2", ImportanceValue, hdr->findField("Importance")->getValue()->generate());
ferencd@0 78
ferencd@0 79 VASSERT_NO_THROW("3", hdr->findField("X-Priority"));
ferencd@0 80 VASSERT_EQ("4", XPriorityValue, hdr->findField("X-Priority")->getValue()->generate());
ferencd@0 81 }
ferencd@0 82
ferencd@0 83 void testSetImportance1()
ferencd@0 84 {
ferencd@0 85 testSetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_HIGHEST,
ferencd@0 86 "high", "1 (Highest)");
ferencd@0 87 }
ferencd@0 88
ferencd@0 89 void testSetImportance2()
ferencd@0 90 {
ferencd@0 91 testSetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_HIGH,
ferencd@0 92 "high", "2 (High)");
ferencd@0 93 }
ferencd@0 94
ferencd@0 95 void testSetImportance3()
ferencd@0 96 {
ferencd@0 97 testSetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_NORMAL,
ferencd@0 98 "normal", "3 (Normal)");
ferencd@0 99 }
ferencd@0 100
ferencd@0 101 void testSetImportance4()
ferencd@0 102 {
ferencd@0 103 testSetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_LOW,
ferencd@0 104 "low", "4 (Low)");
ferencd@0 105 }
ferencd@0 106
ferencd@0 107 void testSetImportance5()
ferencd@0 108 {
ferencd@0 109 testSetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_LOWEST,
ferencd@0 110 "low", "5 (Lowest)");
ferencd@0 111 }
ferencd@0 112
ferencd@0 113
ferencd@0 114 // getImportance
ferencd@0 115
ferencd@0 116 void testGetImportanceImpl(const vmime::misc::importanceHelper::Importance i1,
ferencd@0 117 const vmime::misc::importanceHelper::Importance i2,
ferencd@0 118 const std::string& ImportanceValue, const std::string& XPriorityValue)
ferencd@0 119 {
ferencd@0 120 vmime::shared_ptr <vmime::header> hdr1 = vmime::make_shared <vmime::header>();
ferencd@0 121
ferencd@0 122 hdr1->getField("Importance")->setValue(ImportanceValue);
ferencd@0 123 VASSERT_EQ("1", i1, vmime::misc::importanceHelper::getImportanceHeader(hdr1));
ferencd@0 124
ferencd@0 125 vmime::shared_ptr <vmime::header> hdr2 = vmime::make_shared <vmime::header>();
ferencd@0 126
ferencd@0 127 hdr2->getField("X-Priority")->setValue(XPriorityValue);
ferencd@0 128 VASSERT_EQ("2", i2, vmime::misc::importanceHelper::getImportanceHeader(hdr2));
ferencd@0 129 }
ferencd@0 130
ferencd@0 131 void testGetImportance1()
ferencd@0 132 {
ferencd@0 133 testGetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_HIGHEST,
ferencd@0 134 vmime::misc::importanceHelper::IMPORTANCE_HIGHEST, "high", "1 (Highest)");
ferencd@0 135 }
ferencd@0 136
ferencd@0 137 void testGetImportance2()
ferencd@0 138 {
ferencd@0 139 testGetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_HIGHEST,
ferencd@0 140 vmime::misc::importanceHelper::IMPORTANCE_HIGH, "high", "2 (High)");
ferencd@0 141 }
ferencd@0 142
ferencd@0 143 void testGetImportance3()
ferencd@0 144 {
ferencd@0 145 testGetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_NORMAL,
ferencd@0 146 vmime::misc::importanceHelper::IMPORTANCE_NORMAL, "normal", "3 (Normal)");
ferencd@0 147 }
ferencd@0 148
ferencd@0 149 void testGetImportance4()
ferencd@0 150 {
ferencd@0 151 testGetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_LOWEST,
ferencd@0 152 vmime::misc::importanceHelper::IMPORTANCE_LOW, "low", "4 (Low)");
ferencd@0 153 }
ferencd@0 154
ferencd@0 155 void testGetImportance5()
ferencd@0 156 {
ferencd@0 157 testGetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_LOWEST,
ferencd@0 158 vmime::misc::importanceHelper::IMPORTANCE_LOWEST, "low", "5 (Lowest)");
ferencd@0 159 }
ferencd@0 160
ferencd@0 161 VMIME_TEST_SUITE_END
ferencd@0 162