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 "vmime/misc/importanceHelper.hpp" ferencd@0: ferencd@0: ferencd@0: VMIME_TEST_SUITE_BEGIN(importanceHelperTest) ferencd@0: ferencd@0: VMIME_TEST_LIST_BEGIN ferencd@0: VMIME_TEST(testResetImportance) ferencd@0: ferencd@0: VMIME_TEST(testSetImportance1) ferencd@0: VMIME_TEST(testSetImportance2) ferencd@0: VMIME_TEST(testSetImportance3) ferencd@0: VMIME_TEST(testSetImportance4) ferencd@0: VMIME_TEST(testSetImportance5) ferencd@0: ferencd@0: VMIME_TEST(testGetImportance1) ferencd@0: VMIME_TEST(testGetImportance2) ferencd@0: VMIME_TEST(testGetImportance3) ferencd@0: VMIME_TEST(testGetImportance4) ferencd@0: VMIME_TEST(testGetImportance5) ferencd@0: VMIME_TEST_LIST_END ferencd@0: ferencd@0: ferencd@0: // resetImportance ferencd@0: ferencd@0: void testResetImportance() ferencd@0: { ferencd@0: vmime::shared_ptr hdr = vmime::make_shared (); ferencd@0: ferencd@0: hdr->getField("Importance")->setValue("xxx"); ferencd@0: hdr->getField("X-Priority")->setValue("yyy"); ferencd@0: ferencd@0: VASSERT_NO_THROW("1", hdr->findField("Importance")); ferencd@0: VASSERT_NO_THROW("2", hdr->findField("X-Priority")); ferencd@0: ferencd@0: vmime::misc::importanceHelper::resetImportanceHeader(hdr); ferencd@0: ferencd@0: VASSERT_NULL("3", hdr->findField("Importance")); ferencd@0: VASSERT_NULL("4", hdr->findField("X-Priority")); ferencd@0: } ferencd@0: ferencd@0: ferencd@0: // setImportance ferencd@0: ferencd@0: void testSetImportanceImpl(const vmime::misc::importanceHelper::Importance i, ferencd@0: const std::string& ImportanceValue, const std::string& XPriorityValue) ferencd@0: { ferencd@0: vmime::shared_ptr hdr = vmime::make_shared (); ferencd@0: ferencd@0: vmime::misc::importanceHelper::setImportanceHeader(hdr, i); ferencd@0: ferencd@0: VASSERT_NO_THROW("1", hdr->findField("Importance")); ferencd@0: VASSERT_EQ("2", ImportanceValue, hdr->findField("Importance")->getValue()->generate()); ferencd@0: ferencd@0: VASSERT_NO_THROW("3", hdr->findField("X-Priority")); ferencd@0: VASSERT_EQ("4", XPriorityValue, hdr->findField("X-Priority")->getValue()->generate()); ferencd@0: } ferencd@0: ferencd@0: void testSetImportance1() ferencd@0: { ferencd@0: testSetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_HIGHEST, ferencd@0: "high", "1 (Highest)"); ferencd@0: } ferencd@0: ferencd@0: void testSetImportance2() ferencd@0: { ferencd@0: testSetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_HIGH, ferencd@0: "high", "2 (High)"); ferencd@0: } ferencd@0: ferencd@0: void testSetImportance3() ferencd@0: { ferencd@0: testSetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_NORMAL, ferencd@0: "normal", "3 (Normal)"); ferencd@0: } ferencd@0: ferencd@0: void testSetImportance4() ferencd@0: { ferencd@0: testSetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_LOW, ferencd@0: "low", "4 (Low)"); ferencd@0: } ferencd@0: ferencd@0: void testSetImportance5() ferencd@0: { ferencd@0: testSetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_LOWEST, ferencd@0: "low", "5 (Lowest)"); ferencd@0: } ferencd@0: ferencd@0: ferencd@0: // getImportance ferencd@0: ferencd@0: void testGetImportanceImpl(const vmime::misc::importanceHelper::Importance i1, ferencd@0: const vmime::misc::importanceHelper::Importance i2, ferencd@0: const std::string& ImportanceValue, const std::string& XPriorityValue) ferencd@0: { ferencd@0: vmime::shared_ptr hdr1 = vmime::make_shared (); ferencd@0: ferencd@0: hdr1->getField("Importance")->setValue(ImportanceValue); ferencd@0: VASSERT_EQ("1", i1, vmime::misc::importanceHelper::getImportanceHeader(hdr1)); ferencd@0: ferencd@0: vmime::shared_ptr hdr2 = vmime::make_shared (); ferencd@0: ferencd@0: hdr2->getField("X-Priority")->setValue(XPriorityValue); ferencd@0: VASSERT_EQ("2", i2, vmime::misc::importanceHelper::getImportanceHeader(hdr2)); ferencd@0: } ferencd@0: ferencd@0: void testGetImportance1() ferencd@0: { ferencd@0: testGetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_HIGHEST, ferencd@0: vmime::misc::importanceHelper::IMPORTANCE_HIGHEST, "high", "1 (Highest)"); ferencd@0: } ferencd@0: ferencd@0: void testGetImportance2() ferencd@0: { ferencd@0: testGetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_HIGHEST, ferencd@0: vmime::misc::importanceHelper::IMPORTANCE_HIGH, "high", "2 (High)"); ferencd@0: } ferencd@0: ferencd@0: void testGetImportance3() ferencd@0: { ferencd@0: testGetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_NORMAL, ferencd@0: vmime::misc::importanceHelper::IMPORTANCE_NORMAL, "normal", "3 (Normal)"); ferencd@0: } ferencd@0: ferencd@0: void testGetImportance4() ferencd@0: { ferencd@0: testGetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_LOWEST, ferencd@0: vmime::misc::importanceHelper::IMPORTANCE_LOW, "low", "4 (Low)"); ferencd@0: } ferencd@0: ferencd@0: void testGetImportance5() ferencd@0: { ferencd@0: testGetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_LOWEST, ferencd@0: vmime::misc::importanceHelper::IMPORTANCE_LOWEST, "low", "5 (Lowest)"); ferencd@0: } ferencd@0: ferencd@0: VMIME_TEST_SUITE_END ferencd@0: