Added local file tests, and make URL tests more complete for NormalizeUrl

This commit is contained in:
AdenKoperczak 2024-11-25 12:14:23 -05:00
parent 950620de6e
commit f0bfca8588

View file

@ -12,13 +12,49 @@ namespace util
{ {
const std::vector<std::pair<const std::string, const std::string>> testUrls = { const std::vector<std::pair<const std::string, const std::string>> testUrls = {
{" https://example.com/ ", "https://example.com/"}, {" https://example.com/path/to+a+test/file.txt ",
{"\thttps://example.com/\t", "https://example.com/"}, "https://example.com/path/to+a+test/file.txt"},
{"\nhttps://example.com/\n", "https://example.com/"}, {"\thttps://example.com/path/to+a+test/file.txt\t",
{"\rhttps://example.com/\r", "https://example.com/"}, "https://example.com/path/to+a+test/file.txt"},
{"\r\nhttps://example.com/\r\n", "https://example.com/"}, {"\nhttps://example.com/path/to+a+test/file.txt\n",
{" https://example.com/ ", "https://example.com/"}, "https://example.com/path/to+a+test/file.txt"},
{" \nhttps://example.com/ \n ", "https://example.com/"}, {"\rhttps://example.com/path/to+a+test/file.txt\r",
"https://example.com/path/to+a+test/file.txt"},
{"\r\nhttps://example.com/path/to+a+test/file.txt\r\n",
"https://example.com/path/to+a+test/file.txt"},
{" https://example.com/path/to+a+test/file.txt ",
"https://example.com/path/to+a+test/file.txt"},
{" \nhttps://example.com/path/to+a+test/file.txt \n ",
"https://example.com/path/to+a+test/file.txt"},
// Only tested for this OS because NormalizeUrl uses native separators
#ifdef _WIN32
{" C:\\path\\to a test\\file.txt ", "C:\\path\\to a test\\file.txt"},
{"\tC:\\path\\to a test\\file.txt\t", "C:\\path\\to a test\\file.txt"},
{"\nC:\\path\\to a test\\file.txt\n", "C:\\path\\to a test\\file.txt"},
{"\rC:\\path\\to a test\\file.txt\r", "C:\\path\\to a test\\file.txt"},
{"\r\nC:\\path\\to a test\\file.txt\r\n", "C:\\path\\to a test\\file.txt"},
{" C:\\path\\to a test\\file.txt ", "C:\\path\\to a test\\file.txt"},
{" \nC:\\path\\to a test\\file.txt \n ",
"C:\\path\\to a test\\file.txt"},
{" C:/path/to a test/file.txt ", "C:\\path\\to a test\\file.txt"},
{"\tC:/path/to a test/file.txt\t", "C:\\path\\to a test\\file.txt"},
{"\nC:/path/to a test/file.txt\n", "C:\\path\\to a test\\file.txt"},
{"\rC:/path/to a test/file.txt\r", "C:\\path\\to a test\\file.txt"},
{"\r\nC:/path/to a test/file.txt\r\n", "C:\\path\\to a test\\file.txt"},
{" C:/path/to a test/file.txt ", "C:\\path\\to a test\\file.txt"},
{" \nC:/path/to a test/file.txt \n ", "C:\\path\\to a test\\file.txt"},
#else
{" /path/to a test/file.txt ", "/path/to a test/file.txt"},
{"\t/path/to a test/file.txt\t", "/path/to a test/file.txt"},
{"\n/path/to a test/file.txt\n", "/path/to a test/file.txt"},
{"\r/path/to a test/file.txt\r", "/path/to a test/file.txt"},
{"\r\n/path/to a test/file.txt\r\n", "/path/to a test/file.txt"},
{" /path/to a test/file.txt ", "/path/to a test/file.txt"},
{" \n/path/to a test/file.txt \n ", "/path/to a test/file.txt"},
#endif
}; };
TEST(network, NormalizeUrl) TEST(network, NormalizeUrl)