comparison 3rdparty/vmime/tests/parser/mediaTypeTest.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(mediaTypeTest)
28
29 VMIME_TEST_LIST_BEGIN
30 VMIME_TEST(testConstructors)
31 VMIME_TEST(testCopy)
32 VMIME_TEST(testSetFromString)
33 VMIME_TEST(testParse)
34 VMIME_TEST(testGenerate)
35 VMIME_TEST_LIST_END
36
37
38 void testConstructors()
39 {
40 vmime::mediaType t1;
41
42 VASSERT_EQ("1.1", vmime::mediaTypes::APPLICATION, t1.getType());
43 VASSERT_EQ("1.2", vmime::mediaTypes::APPLICATION_OCTET_STREAM, t1.getSubType());
44
45 vmime::mediaType t2("type", "sub");
46
47 VASSERT_EQ("2.1", "type", t2.getType());
48 VASSERT_EQ("2.2", "sub", t2.getSubType());
49
50 vmime::mediaType t3("type/sub");
51
52 VASSERT_EQ("3.1", "type", t3.getType());
53 VASSERT_EQ("3.2", "sub", t3.getSubType());
54 }
55
56 void testCopy()
57 {
58 vmime::mediaType t1("type/sub");
59
60 VASSERT_EQ("eq1", "type", t1.getType());
61 VASSERT_EQ("eq2", "sub", t1.getSubType());
62
63 VASSERT("operator==", t1 == t1);
64 VASSERT("clone", t1 == *vmime::clone(t1));
65
66 VASSERT_EQ("eq3", "type", vmime::clone(t1)->getType());
67 VASSERT_EQ("eq4", "sub", vmime::clone(t1)->getSubType());
68
69 vmime::mediaType t2;
70 t2.copyFrom(t1);
71
72 VASSERT("copyFrom", t1 == t2);
73 }
74
75 void testSetFromString()
76 {
77 vmime::mediaType t1;
78 t1.setFromString("type/sub");
79
80 VASSERT_EQ("1.1", "type", t1.getType());
81 VASSERT_EQ("1.2", "sub", t1.getSubType());
82 }
83
84 void testParse()
85 {
86 vmime::mediaType t1;
87 t1.parse("type/sub");
88
89 VASSERT_EQ("1.1", "type", t1.getType());
90 VASSERT_EQ("1.2", "sub", t1.getSubType());
91 }
92
93 void testGenerate()
94 {
95 vmime::mediaType t1("type", "sub");
96
97 VASSERT_EQ("1", "type/sub", t1.generate());
98 }
99
100 VMIME_TEST_SUITE_END
101