mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 03:40:05 +00:00
Fixed issue with NormalizeUrl where whitespace trimming was not
happening on non-local files, and added test cases.
This commit is contained in:
parent
b5ac254259
commit
b13d2106d4
3 changed files with 43 additions and 2 deletions
|
|
@ -25,7 +25,7 @@ std::string NormalizeUrl(const std::string& urlString)
|
|||
}
|
||||
else
|
||||
{
|
||||
normalizedUrl = urlString;
|
||||
normalizedUrl = trimmedUrlString.toStdString();
|
||||
}
|
||||
|
||||
return normalizedUrl;
|
||||
|
|
|
|||
40
test/source/scwx/qt/util/network.test.cpp
Normal file
40
test/source/scwx/qt/util/network.test.cpp
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#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
|
||||
|
|
@ -29,7 +29,8 @@ set(SRC_QT_MODEL_TESTS source/scwx/qt/model/imgui_context_model.test.cpp)
|
|||
set(SRC_QT_SETTINGS_TESTS source/scwx/qt/settings/settings_container.test.cpp
|
||||
source/scwx/qt/settings/settings_variable.test.cpp)
|
||||
set(SRC_QT_UTIL_TESTS source/scwx/qt/util/q_file_input_stream.test.cpp
|
||||
source/scwx/qt/util/geographic_lib.test.cpp)
|
||||
source/scwx/qt/util/geographic_lib.test.cpp
|
||||
source/scwx/qt/util/network.test.cpp)
|
||||
set(SRC_UTIL_TESTS source/scwx/util/float.test.cpp
|
||||
source/scwx/util/rangebuf.test.cpp
|
||||
source/scwx/util/streams.test.cpp
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue