util/UriUtil: split
This commit is contained in:
@@ -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>
|
||||
|
||||
|
33
test/TestUriExtract.cxx
Normal file
33
test/TestUriExtract.cxx
Normal file
@@ -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");
|
||||
}
|
@@ -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(),
|
||||
|
@@ -37,6 +37,7 @@ test('TestUtil', executable(
|
||||
'TestDivideString.cxx',
|
||||
'TestMimeType.cxx',
|
||||
'TestSplitString.cxx',
|
||||
'TestUriExtract.cxx',
|
||||
'TestUriUtil.cxx',
|
||||
'test_byte_reverse.cxx',
|
||||
include_directories: inc,
|
||||
|
Reference in New Issue
Block a user