supercell-wx/test/source/scwx/qt/util/network.test.cpp
AdenKoperczak b13d2106d4 Fixed issue with NormalizeUrl where whitespace trimming was not
happening on non-local files, and added test cases.
2024-11-25 11:42:17 -05:00

40 lines
965 B
C++

#include <scwx/qt/util/network.hpp>
#include <gtest/gtest.h>
namespace scwx
{
namespace qt
{
namespace util
{
const std::vector<std::pair<const std::string, const std::string>> testUrls = {
{" https://example.com/ ", "https://example.com/"},
{"\thttps://example.com/\t", "https://example.com/"},
{"\nhttps://example.com/\n", "https://example.com/"},
{"\rhttps://example.com/\r", "https://example.com/"},
{"\r\nhttps://example.com/\r\n", "https://example.com/"},
{" https://example.com/ ", "https://example.com/"},
{" \nhttps://example.com/ \n ", "https://example.com/"},
};
TEST(network, NormalizeUrl)
{
for (auto& pair : testUrls)
{
const std::string& preNormalized = pair.first;
const std::string& expNormalized = pair.second;
std::string normalized = network::NormalizeUrl(preNormalized);
EXPECT_EQ(normalized, expNormalized);
}
}
} // namespace util
} // namespace qt
} // namespace scwx