Formatting

This commit is contained in:
cbclemmer 2023-08-20 14:19:08 -05:00
parent a72bc5f564
commit 45c3e00d9c
2 changed files with 39 additions and 44 deletions

View file

@ -119,7 +119,8 @@ QString sanitizeUrl(const QString &unparsedString)
const QString allowedSpecialCharacters = "!#&+/:=?@-_.";
QString sanitizedUrl;
for (const QChar& c : unparsedString) {
for (const QChar &c : unparsedString)
{
if (c.isLetterOrNumber())
{
sanitizedUrl.append(c);

View file

@ -25,23 +25,19 @@ struct Case {
}
};
struct SanitizeCheck
{
struct SanitizeCheck {
QString testValue{};
QString expectedValue{};
};
TEST(LinkParser, parseDomainLinks)
{
const QList<SanitizeCheck> sanitizeCases = {
{ "(twitch.tv)", "twitch.tv"}
};
const QList<SanitizeCheck> sanitizeCases = {{"(twitch.tv)", "twitch.tv"}};
for (auto &c : sanitizeCases)
{
LinkParser p(c.testValue);
ASSERT_TRUE(p.result().has_value()) << c.testValue.toStdString();
ASSERT_TRUE(p.result().has_value()) << c.testValue.toStdString();
const auto &r = *p.result();
ASSERT_EQ(c.expectedValue, r.host);
}
@ -151,42 +147,40 @@ TEST(LinkParser, doesntParseInvalidIpv4Links)
TEST(LinkParser, doesntParseInvalidLinks)
{
const QStringList inputs = {
"h://foo.com",
"spotify:1234",
"ftp://chatterino.com",
"ftps://chatterino.com",
"spotify://chatterino.com",
"httpsx://chatterino.com",
"https:chatterino.com",
"https:/chatterino.com",
"http:/chatterino.com",
"htp://chatterino.com",
"/chatterino.com",
"word",
".",
"/",
"#",
":",
"?",
"a",
"://chatterino.com",
"//chatterino.com",
"http://pn.",
"http://pn./",
"https://pn./",
"pn./",
"pn.",
"http/chatterino.com",
"http/wiki.chatterino.com",
"http:cat.com",
"https:cat.com",
"http:/cat.com",
"http:/cat.com",
"https:/cat.com",
"%%%%.com",
"*.com"
};
const QStringList inputs = {"h://foo.com",
"spotify:1234",
"ftp://chatterino.com",
"ftps://chatterino.com",
"spotify://chatterino.com",
"httpsx://chatterino.com",
"https:chatterino.com",
"https:/chatterino.com",
"http:/chatterino.com",
"htp://chatterino.com",
"/chatterino.com",
"word",
".",
"/",
"#",
":",
"?",
"a",
"://chatterino.com",
"//chatterino.com",
"http://pn.",
"http://pn./",
"https://pn./",
"pn./",
"pn.",
"http/chatterino.com",
"http/wiki.chatterino.com",
"http:cat.com",
"https:cat.com",
"http:/cat.com",
"http:/cat.com",
"https:/cat.com",
"%%%%.com",
"*.com"};
for (const auto &input : inputs)
{