From eab32f2e5d8114d08e392001f0004284267bebd5 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 1 Nov 2014 12:45:47 +0100 Subject: util/UriUtil: add uri_get_suffix() overload that ignores query string --- test/test_util.cxx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test') diff --git a/test/test_util.cxx b/test/test_util.cxx index aaadec68f..3e79aeca0 100644 --- a/test/test_util.cxx +++ b/test/test_util.cxx @@ -34,6 +34,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() { -- cgit v1.2.3