Mercurial > thymian
comparison 3rdparty/vmime/tests/parser/pathTest.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(pathTest) | |
| 28 | |
| 29 VMIME_TEST_LIST_BEGIN | |
| 30 VMIME_TEST(testParse) | |
| 31 VMIME_TEST(testParse2) | |
| 32 VMIME_TEST(testGenerate) | |
| 33 VMIME_TEST_LIST_END | |
| 34 | |
| 35 | |
| 36 void testParse() | |
| 37 { | |
| 38 vmime::path p1; | |
| 39 p1.parse("<>"); | |
| 40 | |
| 41 VASSERT_EQ("1.1", "", p1.getLocalPart()); | |
| 42 VASSERT_EQ("1.2", "", p1.getDomain()); | |
| 43 | |
| 44 vmime::path p2; | |
| 45 p2.parse("<domain>"); | |
| 46 | |
| 47 VASSERT_EQ("2.1", "", p2.getLocalPart()); | |
| 48 VASSERT_EQ("2.2", "domain", p2.getDomain()); | |
| 49 | |
| 50 vmime::path p3; | |
| 51 p3.parse("<local@domain>"); | |
| 52 | |
| 53 VASSERT_EQ("3.1", "local", p3.getLocalPart()); | |
| 54 VASSERT_EQ("3.2", "domain", p3.getDomain()); | |
| 55 } | |
| 56 | |
| 57 void testParse2() | |
| 58 { | |
| 59 // Test some invalid paths (no '<>') | |
| 60 vmime::path p1; | |
| 61 p1.parse(""); | |
| 62 | |
| 63 VASSERT_EQ("1.1", "", p1.getLocalPart()); | |
| 64 VASSERT_EQ("1.2", "", p1.getDomain()); | |
| 65 | |
| 66 vmime::path p2; | |
| 67 p2.parse("domain"); | |
| 68 | |
| 69 VASSERT_EQ("2.1", "", p2.getLocalPart()); | |
| 70 VASSERT_EQ("2.2", "domain", p2.getDomain()); | |
| 71 | |
| 72 vmime::path p3; | |
| 73 p3.parse("local@domain"); | |
| 74 | |
| 75 VASSERT_EQ("3.1", "local", p3.getLocalPart()); | |
| 76 VASSERT_EQ("3.2", "domain", p3.getDomain()); | |
| 77 } | |
| 78 | |
| 79 void testGenerate() | |
| 80 { | |
| 81 vmime::path p1; | |
| 82 | |
| 83 VASSERT_EQ("1", "<>", p1.generate()); | |
| 84 | |
| 85 vmime::path p2; | |
| 86 p2.setLocalPart("local"); | |
| 87 | |
| 88 VASSERT_EQ("2", "<local@>", p2.generate()); | |
| 89 | |
| 90 vmime::path p3; | |
| 91 p3.setDomain("domain"); | |
| 92 | |
| 93 VASSERT_EQ("3", "<@domain>", p3.generate()); | |
| 94 | |
| 95 vmime::path p4; | |
| 96 p4.setLocalPart("local"); | |
| 97 p4.setDomain("domain"); | |
| 98 | |
| 99 VASSERT_EQ("4", "<local@domain>", p4.generate()); | |
| 100 } | |
| 101 | |
| 102 VMIME_TEST_SUITE_END | |
| 103 |
