1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <sal/config.h>
14 #include <cppunit/TestAssert.h>
15 #include <cppunit/TestFixture.h>
16 #include <cppunit/TestSuite.h>
17 #include <cppunit/extensions/HelperMacros.h>
18 #include <cppunit/plugin/TestPlugIn.h>
19 #include <rtl/ustring.hxx>
20 #include <svl/inettype.hxx>
21 #include <tools/inetmime.hxx>
25 class Test
: public CppUnit::TestFixture
{
33 CPPUNIT_TEST_SUITE(Test
);
34 CPPUNIT_TEST(testBad
);
35 CPPUNIT_TEST(testFull
);
36 CPPUNIT_TEST(testFollow
);
37 CPPUNIT_TEST_SUITE_END();
40 void Test::testBad() {
41 OUString
in("foo=bar");
43 static_cast<sal_Unicode
const *>(0),
44 INetMIME::scanContentType(in
.getStr(), in
.getStr() + in
.getLength()));
47 INetContentTypeParameterList ps
;
48 CPPUNIT_ASSERT(!INetContentTypes::parse(in
, t
, s
, &ps
));
49 CPPUNIT_ASSERT(t
.isEmpty());
50 CPPUNIT_ASSERT(s
.isEmpty());
52 static_cast<INetContentTypeParameter
const *>(0), ps
.find("foo"));
55 void Test::testFull() {
56 OUString
in("foo/bar;baz=boz");
58 in
.getStr() + in
.getLength(),
59 INetMIME::scanContentType(in
.getStr(), in
.getStr() + in
.getLength()));
62 INetContentTypeParameterList ps
;
63 CPPUNIT_ASSERT(INetContentTypes::parse(in
, t
, s
, &ps
));
64 CPPUNIT_ASSERT_EQUAL(OUString("foo"), t
);
65 CPPUNIT_ASSERT_EQUAL(OUString("bar"), s
);
66 INetContentTypeParameter
const * p
= ps
.find("baz");
67 CPPUNIT_ASSERT(p
!= 0);
68 CPPUNIT_ASSERT_EQUAL(OUString("boz"), p
->m_sValue
);
71 void Test::testFollow() {
72 OUString
in("foo/bar;baz=boz;base64,");
74 in
.getStr() + std::strlen("foo/bar;baz=boz"),
75 INetMIME::scanContentType(in
.getStr(), in
.getStr() + in
.getLength()));
78 INetContentTypeParameterList ps
;
79 CPPUNIT_ASSERT(!INetContentTypes::parse(in
, t
, s
));
80 CPPUNIT_ASSERT(t
.isEmpty());
81 CPPUNIT_ASSERT(s
.isEmpty());
83 static_cast<INetContentTypeParameter
const *>(0), ps
.find("baz"));
86 CPPUNIT_TEST_SUITE_REGISTRATION(Test
);
90 CPPUNIT_PLUGIN_IMPLEMENT();
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */