diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-04-12 13:39:52 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-04-12 13:39:52 +0200 |
commit | c4d02f488d6ca85e25f231db27eaba4ca3085db0 (patch) | |
tree | edac9a5b0476020c7e518d78025d96a46ee64ebf /tools/qa | |
parent | a3c294e6ad33c43b7c515b9bf543aa4bb27a7d51 (diff) |
Add minimal INetMIME::scanContentType test and fix bugs thus found
Change-Id: I8fcbeb2b0804bc4f9ee8f97f7d02737ba79a7f20
Diffstat (limited to 'tools/qa')
-rw-r--r-- | tools/qa/cppunit/test_inetmime.cxx | 26 |
1 files changed, 26 insertions, 0 deletions
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: */ |