aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-11-01 12:45:47 +0100
committerMax Kellermann <max@duempel.org>2014-11-02 11:53:31 +0100
commit674091424e715fddd8fbfe8146f351da5bf84974 (patch)
treebdbcf6f8d7276fa278baf1750e27992f679a2474 /test
parent6ad336743d861a03df3079058fdc18eee07a3014 (diff)
downloadmpd-674091424e715fddd8fbfe8146f351da5bf84974.tar.gz
mpd-674091424e715fddd8fbfe8146f351da5bf84974.tar.xz
mpd-674091424e715fddd8fbfe8146f351da5bf84974.zip
util/UriUtil: add uri_get_suffix() overload that ignores query string
Diffstat (limited to 'test')
-rw-r--r--test/test_util.cxx19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/test_util.cxx b/test/test_util.cxx
index a472391a3..91e87957f 100644
--- a/test/test_util.cxx
+++ b/test/test_util.cxx
@@ -33,6 +33,25 @@ public:
uri_get_suffix(".jpg"));
CPPUNIT_ASSERT_EQUAL((const char *)nullptr,
uri_get_suffix("/foo/.jpg"));
+
+ /* the first overload does not eliminate the query
+ string */
+ CPPUNIT_ASSERT_EQUAL(0, strcmp(uri_get_suffix("/foo/bar.jpg?query_string"),
+ "jpg?query_string"));
+
+ /* ... but the second one does */
+ UriSuffixBuffer buffer;
+ CPPUNIT_ASSERT_EQUAL(0, strcmp(uri_get_suffix("/foo/bar.jpg?query_string",
+ buffer),
+ "jpg"));
+
+ /* repeat some of the above tests with the second overload */
+ CPPUNIT_ASSERT_EQUAL((const char *)nullptr,
+ uri_get_suffix("/foo/bar", buffer));
+ CPPUNIT_ASSERT_EQUAL((const char *)nullptr,
+ uri_get_suffix("/foo.jpg/bar", buffer));
+ CPPUNIT_ASSERT_EQUAL(0, strcmp(uri_get_suffix("/foo/bar.jpg", buffer),
+ "jpg"));
}
void TestRemoveAuth() {