Mercurial > thymian
comparison 3rdparty/vmime/tests/net/folderAttributesTest.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-2014 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/net/folderAttributes.hpp" | |
| 27 | |
| 28 | |
| 29 VMIME_TEST_SUITE_BEGIN(folderAttributesTest) | |
| 30 | |
| 31 VMIME_TEST_LIST_BEGIN | |
| 32 VMIME_TEST(testConstruct) | |
| 33 VMIME_TEST(testConstructCopy) | |
| 34 VMIME_TEST(testSetType) | |
| 35 VMIME_TEST(testSetFlags) | |
| 36 VMIME_TEST(testHasFlag) | |
| 37 VMIME_TEST(testSetUserFlags) | |
| 38 VMIME_TEST(testHasUserFlag) | |
| 39 VMIME_TEST(testSetSpecialUse) | |
| 40 VMIME_TEST_LIST_END | |
| 41 | |
| 42 | |
| 43 void testConstruct() | |
| 44 { | |
| 45 vmime::net::folderAttributes attr; | |
| 46 | |
| 47 // Default values | |
| 48 VASSERT_EQ("type", vmime::net::folderAttributes::TYPE_CONTAINS_FOLDERS | |
| 49 | vmime::net::folderAttributes::TYPE_CONTAINS_MESSAGES, attr.getType()); | |
| 50 VASSERT_EQ("flags", 0, attr.getFlags()); | |
| 51 VASSERT_EQ("user-flags", 0, attr.getUserFlags().size()); | |
| 52 VASSERT_EQ("special-use", vmime::net::folderAttributes::SPECIALUSE_NONE, attr.getSpecialUse()); | |
| 53 } | |
| 54 | |
| 55 void testConstructCopy() | |
| 56 { | |
| 57 std::vector <vmime::string> userFlags; | |
| 58 userFlags.push_back("\\XMyFlag1"); | |
| 59 userFlags.push_back("\\XMyFlag2"); | |
| 60 userFlags.push_back("\\XMyFlag3"); | |
| 61 | |
| 62 vmime::net::folderAttributes attr; | |
| 63 | |
| 64 attr.setFlags(vmime::net::folderAttributes::FLAG_HAS_CHILDREN); | |
| 65 attr.setUserFlags(userFlags); | |
| 66 | |
| 67 vmime::net::folderAttributes attr2(attr); | |
| 68 | |
| 69 VASSERT("flags", attr2.getFlags() == attr.getFlags()); | |
| 70 VASSERT("user-flags", attr2.getUserFlags() == attr.getUserFlags()); | |
| 71 } | |
| 72 | |
| 73 void testSetType() | |
| 74 { | |
| 75 vmime::net::folderAttributes attr; | |
| 76 attr.setType(vmime::net::folderAttributes::TYPE_CONTAINS_FOLDERS); | |
| 77 | |
| 78 VASSERT_EQ("eq", vmime::net::folderAttributes::TYPE_CONTAINS_FOLDERS, attr.getType()); | |
| 79 } | |
| 80 | |
| 81 void testSetFlags() | |
| 82 { | |
| 83 vmime::net::folderAttributes attr; | |
| 84 attr.setFlags(vmime::net::folderAttributes::FLAG_HAS_CHILDREN); | |
| 85 | |
| 86 VASSERT_EQ("eq", vmime::net::folderAttributes::FLAG_HAS_CHILDREN, attr.getFlags()); | |
| 87 } | |
| 88 | |
| 89 void testHasFlag() | |
| 90 { | |
| 91 vmime::net::folderAttributes attr; | |
| 92 attr.setFlags(vmime::net::folderAttributes::FLAG_HAS_CHILDREN); | |
| 93 | |
| 94 VASSERT("has", attr.hasFlag(vmime::net::folderAttributes::FLAG_HAS_CHILDREN)); | |
| 95 VASSERT("has-not", !attr.hasFlag(vmime::net::folderAttributes::FLAG_NO_OPEN)); | |
| 96 } | |
| 97 | |
| 98 void testSetUserFlags() | |
| 99 { | |
| 100 std::vector <vmime::string> userFlags; | |
| 101 userFlags.push_back("\\XMyFlag1"); | |
| 102 userFlags.push_back("\\XMyFlag2"); | |
| 103 userFlags.push_back("\\XMyFlag3"); | |
| 104 | |
| 105 vmime::net::folderAttributes attr; | |
| 106 attr.setUserFlags(userFlags); | |
| 107 | |
| 108 VASSERT("eq", attr.getUserFlags() == userFlags); | |
| 109 } | |
| 110 | |
| 111 void testHasUserFlag() | |
| 112 { | |
| 113 std::vector <vmime::string> userFlags; | |
| 114 userFlags.push_back("\\XMyFlag1"); | |
| 115 userFlags.push_back("\\XMyFlag2"); | |
| 116 userFlags.push_back("\\XMyFlag3"); | |
| 117 | |
| 118 vmime::net::folderAttributes attr; | |
| 119 attr.setUserFlags(userFlags); | |
| 120 | |
| 121 VASSERT("has", attr.hasUserFlag("\\XMyFlag1")); | |
| 122 VASSERT("has-casesensitive", !attr.hasUserFlag("\\xmyflag1")); | |
| 123 VASSERT("has-not", !attr.hasUserFlag("\\XMyFlag4")); | |
| 124 } | |
| 125 | |
| 126 void testSetSpecialUse() | |
| 127 { | |
| 128 const int use = vmime::net::folderAttributes::SPECIALUSE_JUNK | |
| 129 | vmime::net::folderAttributes::SPECIALUSE_TRASH; | |
| 130 | |
| 131 vmime::net::folderAttributes attr; | |
| 132 attr.setSpecialUse(use); | |
| 133 | |
| 134 VASSERT_EQ("eq", use, attr.getSpecialUse()); | |
| 135 } | |
| 136 | |
| 137 VMIME_TEST_SUITE_END |
