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