2004-11-07 09:49:05 +00:00
|
|
|
//
|
2005-03-18 21:33:11 +00:00
|
|
|
// VMime library (http://www.vmime.org)
|
2008-01-04 18:07:40 +00:00
|
|
|
// Copyright (C) 2002-2008 Vincent Richard <vincent@vincent-richard.net>
|
2004-11-07 09:49:05 +00:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of
|
|
|
|
// the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
2005-09-17 10:10:29 +00:00
|
|
|
// You should have received a copy of the GNU General Public License along
|
|
|
|
// with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
//
|
|
|
|
// Linking this library statically or dynamically with other modules is making
|
|
|
|
// a combined work based on this library. Thus, the terms and conditions of
|
|
|
|
// the GNU General Public License cover the whole combination.
|
2004-11-07 09:49:05 +00:00
|
|
|
//
|
|
|
|
|
2005-08-25 21:25:45 +00:00
|
|
|
#include "tests/testUtils.hpp"
|
2004-11-07 09:49:05 +00:00
|
|
|
|
|
|
|
|
2005-08-25 21:25:45 +00:00
|
|
|
#define VMIME_TEST_SUITE mediaTypeTest
|
|
|
|
#define VMIME_TEST_SUITE_MODULE "Parser"
|
2004-11-07 09:49:05 +00:00
|
|
|
|
|
|
|
|
2005-08-25 21:25:45 +00:00
|
|
|
VMIME_TEST_SUITE_BEGIN
|
2004-11-07 09:49:05 +00:00
|
|
|
|
2005-08-25 21:25:45 +00:00
|
|
|
VMIME_TEST_LIST_BEGIN
|
|
|
|
VMIME_TEST(testConstructors)
|
|
|
|
VMIME_TEST(testCopy)
|
|
|
|
VMIME_TEST(testSetFromString)
|
|
|
|
VMIME_TEST(testParse)
|
|
|
|
VMIME_TEST(testGenerate)
|
|
|
|
VMIME_TEST_LIST_END
|
2004-11-07 09:49:05 +00:00
|
|
|
|
|
|
|
|
2005-08-25 21:25:45 +00:00
|
|
|
void testConstructors()
|
|
|
|
{
|
|
|
|
vmime::mediaType t1;
|
2004-11-07 09:49:05 +00:00
|
|
|
|
2005-08-25 21:25:45 +00:00
|
|
|
VASSERT_EQ("1.1", vmime::mediaTypes::APPLICATION, t1.getType());
|
|
|
|
VASSERT_EQ("1.2", vmime::mediaTypes::APPLICATION_OCTET_STREAM, t1.getSubType());
|
2004-11-07 09:49:05 +00:00
|
|
|
|
2005-08-25 21:25:45 +00:00
|
|
|
vmime::mediaType t2("type", "sub");
|
2004-11-07 09:49:05 +00:00
|
|
|
|
2005-08-25 21:25:45 +00:00
|
|
|
VASSERT_EQ("2.1", "type", t2.getType());
|
|
|
|
VASSERT_EQ("2.2", "sub", t2.getSubType());
|
2004-11-07 09:49:05 +00:00
|
|
|
|
2005-08-25 21:25:45 +00:00
|
|
|
vmime::mediaType t3("type/sub");
|
2004-11-07 09:49:05 +00:00
|
|
|
|
2005-08-25 21:25:45 +00:00
|
|
|
VASSERT_EQ("3.1", "type", t3.getType());
|
|
|
|
VASSERT_EQ("3.2", "sub", t3.getSubType());
|
|
|
|
}
|
2004-11-07 09:49:05 +00:00
|
|
|
|
2005-08-25 21:25:45 +00:00
|
|
|
void testCopy()
|
|
|
|
{
|
|
|
|
vmime::mediaType t1("type/sub");
|
2004-11-07 09:49:05 +00:00
|
|
|
|
2005-08-25 21:25:45 +00:00
|
|
|
VASSERT_EQ("eq1", "type", t1.getType());
|
|
|
|
VASSERT_EQ("eq2", "sub", t1.getSubType());
|
2004-11-07 09:49:05 +00:00
|
|
|
|
2005-08-25 21:25:45 +00:00
|
|
|
VASSERT("operator==", t1 == t1);
|
|
|
|
VASSERT("clone", t1 == *vmime::clone(t1));
|
2004-11-07 09:49:05 +00:00
|
|
|
|
2005-08-25 21:25:45 +00:00
|
|
|
VASSERT_EQ("eq3", "type", vmime::clone(t1)->getType());
|
|
|
|
VASSERT_EQ("eq4", "sub", vmime::clone(t1)->getSubType());
|
2004-11-07 09:49:05 +00:00
|
|
|
|
2005-08-25 21:25:45 +00:00
|
|
|
vmime::mediaType t2;
|
|
|
|
t2.copyFrom(t1);
|
2004-11-07 09:49:05 +00:00
|
|
|
|
2005-08-25 21:25:45 +00:00
|
|
|
VASSERT("copyFrom", t1 == t2);
|
|
|
|
}
|
2004-11-07 09:49:05 +00:00
|
|
|
|
2005-08-25 21:25:45 +00:00
|
|
|
void testSetFromString()
|
|
|
|
{
|
|
|
|
vmime::mediaType t1;
|
|
|
|
t1.setFromString("type/sub");
|
2004-11-07 09:49:05 +00:00
|
|
|
|
2005-08-25 21:25:45 +00:00
|
|
|
VASSERT_EQ("1.1", "type", t1.getType());
|
|
|
|
VASSERT_EQ("1.2", "sub", t1.getSubType());
|
|
|
|
}
|
2004-11-07 09:49:05 +00:00
|
|
|
|
2005-08-25 21:25:45 +00:00
|
|
|
void testParse()
|
|
|
|
{
|
|
|
|
vmime::mediaType t1;
|
|
|
|
t1.parse("type/sub");
|
2004-11-07 09:49:05 +00:00
|
|
|
|
2005-08-25 21:25:45 +00:00
|
|
|
VASSERT_EQ("1.1", "type", t1.getType());
|
|
|
|
VASSERT_EQ("1.2", "sub", t1.getSubType());
|
|
|
|
}
|
2004-11-07 09:49:05 +00:00
|
|
|
|
2005-08-25 21:25:45 +00:00
|
|
|
void testGenerate()
|
|
|
|
{
|
|
|
|
vmime::mediaType t1("type", "sub");
|
2004-11-07 09:49:05 +00:00
|
|
|
|
2005-08-25 21:25:45 +00:00
|
|
|
VASSERT_EQ("1", "type/sub", t1.generate());
|
|
|
|
}
|
2004-11-07 09:49:05 +00:00
|
|
|
|
2005-08-25 21:25:45 +00:00
|
|
|
VMIME_TEST_SUITE_END
|
2004-11-07 09:49:05 +00:00
|
|
|
|