diff options
author | Max Kellermann <max@duempel.org> | 2016-06-10 22:31:26 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2016-06-10 22:52:35 +0200 |
commit | 287ef181bad16f8c8f90ee95a046f4c2a91908db (patch) | |
tree | 90ec7518bd0bd9e5b0cc2684268a06cb4085b96d /test/MimeTypeTest.hxx | |
parent | bc63810ebddde08c133084c377b46616c370bbaa (diff) |
util/MimeType: add ParseMimeTypeParameters()
Diffstat (limited to 'test/MimeTypeTest.hxx')
-rw-r--r-- | test/MimeTypeTest.hxx | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/MimeTypeTest.hxx b/test/MimeTypeTest.hxx index 0e243e6ba..2d4286279 100644 --- a/test/MimeTypeTest.hxx +++ b/test/MimeTypeTest.hxx @@ -13,6 +13,7 @@ class MimeTypeTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(MimeTypeTest); CPPUNIT_TEST(TestBase); + CPPUNIT_TEST(TestParameters); CPPUNIT_TEST_SUITE_END(); public: @@ -25,4 +26,24 @@ public: CPPUNIT_ASSERT("foo/bar" == GetMimeTypeBase("foo/bar; x=y")); CPPUNIT_ASSERT("foo/bar" == GetMimeTypeBase("foo/bar;x=y")); } + + void TestParameters() { + CPPUNIT_ASSERT(ParseMimeTypeParameters("").empty()); + CPPUNIT_ASSERT(ParseMimeTypeParameters("foo/bar").empty()); + CPPUNIT_ASSERT(ParseMimeTypeParameters("foo/bar;").empty()); + CPPUNIT_ASSERT(ParseMimeTypeParameters("foo/bar;garbage").empty()); + CPPUNIT_ASSERT(ParseMimeTypeParameters("foo/bar; garbage").empty()); + + auto p = ParseMimeTypeParameters("foo/bar;a=b"); + CPPUNIT_ASSERT(!p.empty()); + CPPUNIT_ASSERT(p["a"] == "b"); + CPPUNIT_ASSERT(p.size() == 1); + + p = ParseMimeTypeParameters("foo/bar; a=b;c;d=e ; f=g "); + CPPUNIT_ASSERT(!p.empty()); + CPPUNIT_ASSERT(p["a"] == "b"); + CPPUNIT_ASSERT(p["d"] == "e"); + CPPUNIT_ASSERT(p["f"] == "g"); + CPPUNIT_ASSERT(p.size() == 3); + } }; |