summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2019-08-09 15:54:13 +0200
committerMax Kellermann <max@musicpd.org>2019-08-09 20:21:12 +0200
commit40a288085769e83354d619500721911561b16f26 (patch)
treef6c049d0e2f6f1f20440a70dba4a49ac42f680e9 /test
parentade712d7117cec59f7daba80d983238de3ce305a (diff)
util/UriUtil: split
Diffstat (limited to 'test')
-rw-r--r--test/ContainerScan.cxx2
-rw-r--r--test/TestUriExtract.cxx33
-rw-r--r--test/TestUriUtil.cxx26
-rw-r--r--test/meson.build1
4 files changed, 35 insertions, 27 deletions
diff --git a/test/ContainerScan.cxx b/test/ContainerScan.cxx
index 1c40806d6..952de4fb2 100644
--- a/test/ContainerScan.cxx
+++ b/test/ContainerScan.cxx
@@ -25,8 +25,8 @@
#include "fs/Path.hxx"
#include "fs/io/StdioOutputStream.hxx"
#include "fs/io/BufferedOutputStream.hxx"
-#include "util/UriUtil.hxx"
#include "util/PrintException.hxx"
+#include "util/UriExtract.hxx"
#include <stdexcept>
diff --git a/test/TestUriExtract.cxx b/test/TestUriExtract.cxx
new file mode 100644
index 000000000..b5e4c8656
--- /dev/null
+++ b/test/TestUriExtract.cxx
@@ -0,0 +1,33 @@
+/*
+ * Unit tests for src/util/
+ */
+
+#include "util/UriExtract.hxx"
+
+#include <gtest/gtest.h>
+
+TEST(UriExtract, Suffix)
+{
+ EXPECT_EQ((const char *)nullptr, uri_get_suffix("/foo/bar"));
+ EXPECT_EQ((const char *)nullptr, uri_get_suffix("/foo.jpg/bar"));
+ EXPECT_STREQ(uri_get_suffix("/foo/bar.jpg"), "jpg");
+ EXPECT_STREQ(uri_get_suffix("/foo.png/bar.jpg"), "jpg");
+ EXPECT_EQ((const char *)nullptr, uri_get_suffix(".jpg"));
+ EXPECT_EQ((const char *)nullptr, uri_get_suffix("/foo/.jpg"));
+
+ /* the first overload does not eliminate the query
+ string */
+ EXPECT_STREQ(uri_get_suffix("/foo/bar.jpg?query_string"),
+ "jpg?query_string");
+
+ /* ... but the second one does */
+ UriSuffixBuffer buffer;
+ EXPECT_STREQ(uri_get_suffix("/foo/bar.jpg?query_string", buffer),
+ "jpg");
+
+ /* repeat some of the above tests with the second overload */
+ EXPECT_EQ((const char *)nullptr, uri_get_suffix("/foo/bar", buffer));
+ EXPECT_EQ((const char *)nullptr,
+ uri_get_suffix("/foo.jpg/bar", buffer));
+ EXPECT_STREQ(uri_get_suffix("/foo/bar.jpg", buffer), "jpg");
+}
diff --git a/test/TestUriUtil.cxx b/test/TestUriUtil.cxx
index 21cbd2cdf..17a6189e9 100644
--- a/test/TestUriUtil.cxx
+++ b/test/TestUriUtil.cxx
@@ -6,32 +6,6 @@
#include <gtest/gtest.h>
-TEST(UriUtil, Suffix)
-{
- EXPECT_EQ((const char *)nullptr, uri_get_suffix("/foo/bar"));
- EXPECT_EQ((const char *)nullptr, uri_get_suffix("/foo.jpg/bar"));
- EXPECT_STREQ(uri_get_suffix("/foo/bar.jpg"), "jpg");
- EXPECT_STREQ(uri_get_suffix("/foo.png/bar.jpg"), "jpg");
- EXPECT_EQ((const char *)nullptr, uri_get_suffix(".jpg"));
- EXPECT_EQ((const char *)nullptr, uri_get_suffix("/foo/.jpg"));
-
- /* the first overload does not eliminate the query
- string */
- EXPECT_STREQ(uri_get_suffix("/foo/bar.jpg?query_string"),
- "jpg?query_string");
-
- /* ... but the second one does */
- UriSuffixBuffer buffer;
- EXPECT_STREQ(uri_get_suffix("/foo/bar.jpg?query_string", buffer),
- "jpg");
-
- /* repeat some of the above tests with the second overload */
- EXPECT_EQ((const char *)nullptr, uri_get_suffix("/foo/bar", buffer));
- EXPECT_EQ((const char *)nullptr,
- uri_get_suffix("/foo.jpg/bar", buffer));
- EXPECT_STREQ(uri_get_suffix("/foo/bar.jpg", buffer), "jpg");
-}
-
TEST(UriUtil, RemoveAuth)
{
EXPECT_EQ(std::string(),
diff --git a/test/meson.build b/test/meson.build
index d426731ac..4a146dcf9 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -37,6 +37,7 @@ test('TestUtil', executable(
'TestDivideString.cxx',
'TestMimeType.cxx',
'TestSplitString.cxx',
+ 'TestUriExtract.cxx',
'TestUriUtil.cxx',
'test_byte_reverse.cxx',
include_directories: inc,