From c4d02f488d6ca85e25f231db27eaba4ca3085db0 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Wed, 12 Apr 2017 13:39:52 +0200 Subject: Add minimal INetMIME::scanContentType test and fix bugs thus found Change-Id: I8fcbeb2b0804bc4f9ee8f97f7d02737ba79a7f20 --- tools/qa/cppunit/test_inetmime.cxx | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tools/qa') diff --git a/tools/qa/cppunit/test_inetmime.cxx b/tools/qa/cppunit/test_inetmime.cxx index 50973dff8649..1a5d16b5aba6 100644 --- a/tools/qa/cppunit/test_inetmime.cxx +++ b/tools/qa/cppunit/test_inetmime.cxx @@ -35,8 +35,11 @@ namespace public: void test_decodeHeaderFieldBody(); + void test_scanContentType(); + CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST(test_decodeHeaderFieldBody); + CPPUNIT_TEST(test_scanContentType); CPPUNIT_TEST_SUITE_END(); }; @@ -53,6 +56,29 @@ namespace CPPUNIT_ASSERT(testDecode("=?iso-8859-1?B?QUJD?=", "ABC")); } + void Test::test_scanContentType() + { + { + OUString input + = "TEST/subTST; parm1*0*=US-ASCII'En'5%25%20; Parm1*1*=of%2010"; + OUString type; + OUString subType; + INetContentTypeParameterList parameters; + auto end = INetMIME::scanContentType( + input.getStr(), input.getStr() + input.getLength(), &type, + &subType, ¶meters); + CPPUNIT_ASSERT(end != nullptr); + CPPUNIT_ASSERT_EQUAL(OUString(), OUString(end)); + CPPUNIT_ASSERT_EQUAL(OUString("test"), type); + CPPUNIT_ASSERT_EQUAL(OUString("subtst"), subType); + CPPUNIT_ASSERT_EQUAL( + INetContentTypeParameterList::size_type(1), parameters.size()); + auto i = parameters.find("parm1"); + CPPUNIT_ASSERT(i != parameters.end()); + CPPUNIT_ASSERT_EQUAL(OUString("5% of 10"), i->second.m_sValue); + } + } + CPPUNIT_TEST_SUITE_REGISTRATION(Test); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit