diff options
author | Max Kellermann <max@musicpd.org> | 2018-10-16 19:01:13 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-10-16 21:26:04 +0200 |
commit | 01b6e1cbf28f54793e22cc40affac7fb03511180 (patch) | |
tree | 5ac27527b2c5f36384f2c42d3907f12fa96067af /test/TestMimeType.cxx | |
parent | eefc0f5d80fbcb485db230c3df090b69994a75ce (diff) |
test: use GTest instead of cppunit
Diffstat (limited to 'test/TestMimeType.cxx')
-rw-r--r-- | test/TestMimeType.cxx | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/TestMimeType.cxx b/test/TestMimeType.cxx new file mode 100644 index 000000000..5f110172c --- /dev/null +++ b/test/TestMimeType.cxx @@ -0,0 +1,40 @@ +/* + * Unit tests for src/util/ + */ + +#include "config.h" +#include "util/MimeType.hxx" + +#include <gtest/gtest.h> + +TEST(MimeType, Base) +{ + EXPECT_EQ("", GetMimeTypeBase("")); + EXPECT_EQ("", GetMimeTypeBase(";")); + EXPECT_EQ("foo", GetMimeTypeBase("foo")); + EXPECT_EQ("foo/bar", GetMimeTypeBase("foo/bar")); + EXPECT_EQ("foo/bar", GetMimeTypeBase("foo/bar;")); + EXPECT_EQ("foo/bar", GetMimeTypeBase("foo/bar; x=y")); + EXPECT_EQ("foo/bar", GetMimeTypeBase("foo/bar;x=y")); +} + +TEST(UriUtil, Parameters) +{ + EXPECT_TRUE(ParseMimeTypeParameters("").empty()); + EXPECT_TRUE(ParseMimeTypeParameters("foo/bar").empty()); + EXPECT_TRUE(ParseMimeTypeParameters("foo/bar;").empty()); + EXPECT_TRUE(ParseMimeTypeParameters("foo/bar;garbage").empty()); + EXPECT_TRUE(ParseMimeTypeParameters("foo/bar; garbage").empty()); + + auto p = ParseMimeTypeParameters("foo/bar;a=b"); + EXPECT_FALSE(p.empty()); + EXPECT_EQ(p["a"], "b"); + EXPECT_EQ(p.size(), 1u); + + p = ParseMimeTypeParameters("foo/bar; a=b;c;d=e ; f=g "); + EXPECT_FALSE(p.empty()); + EXPECT_EQ(p["a"], "b"); + EXPECT_EQ(p["d"], "e"); + EXPECT_EQ(p["f"], "g"); + EXPECT_EQ(p.size(), 3u); +} |