2020
2121QTEST_GUILESS_MAIN (TestUrlTools)
2222
23- void TestUrlTools::initTestCase()
24- {
25- m_urlTools = urlTools ();
26- }
27-
28- void TestUrlTools::init ()
29- {
30- }
31-
3223void TestUrlTools::testTopLevelDomain()
3324{
3425 // Create list of URLs and expected TLD responses
@@ -48,7 +39,7 @@ void TestUrlTools::testTopLevelDomain()
4839 };
4940
5041 for (const auto & u : tldUrls) {
51- QCOMPARE (urlTools ()-> getTopLevelDomainFromUrl (u.first ), u.second );
42+ QCOMPARE (UrlTools:: getTopLevelDomainFromUrl (u.first ), u.second );
5243 }
5344
5445 // Create list of URLs and expected base URL responses
@@ -66,7 +57,7 @@ void TestUrlTools::testTopLevelDomain()
6657 };
6758
6859 for (const auto & u : baseUrls) {
69- QCOMPARE (urlTools ()-> getBaseDomainFromUrl (u.first ), u.second );
60+ QCOMPARE (UrlTools:: getBaseDomainFromUrl (u.first ), u.second );
7061 }
7162}
7263
@@ -84,32 +75,32 @@ void TestUrlTools::testIsIpAddress()
8475 auto host10 = " ::" ;
8576 auto host11 = " [2001:20::1]" ;
8677
87- QVERIFY (!urlTools ()-> isIpAddress (host1));
88- QVERIFY (urlTools ()-> isIpAddress (host2));
89- QVERIFY (!urlTools ()-> isIpAddress (host3));
90- QVERIFY (urlTools ()-> isIpAddress (host4));
91- QVERIFY (urlTools ()-> isIpAddress (host5));
92- QVERIFY (urlTools ()-> isIpAddress (host6));
93- QVERIFY (urlTools ()-> isIpAddress (host7));
94- QVERIFY (!urlTools ()-> isIpAddress (host8));
95- QVERIFY (urlTools ()-> isIpAddress (host9));
96- QVERIFY (urlTools ()-> isIpAddress (host10));
97- QVERIFY (urlTools ()-> isIpAddress (host11));
78+ QVERIFY (!UrlTools:: isIpAddress (host1));
79+ QVERIFY (UrlTools:: isIpAddress (host2));
80+ QVERIFY (!UrlTools:: isIpAddress (host3));
81+ QVERIFY (UrlTools:: isIpAddress (host4));
82+ QVERIFY (UrlTools:: isIpAddress (host5));
83+ QVERIFY (UrlTools:: isIpAddress (host6));
84+ QVERIFY (UrlTools:: isIpAddress (host7));
85+ QVERIFY (!UrlTools:: isIpAddress (host8));
86+ QVERIFY (UrlTools:: isIpAddress (host9));
87+ QVERIFY (UrlTools:: isIpAddress (host10));
88+ QVERIFY (UrlTools:: isIpAddress (host11));
9889}
9990
10091void TestUrlTools::testIsUrlIdentical ()
10192{
102- QVERIFY (urlTools ()-> isUrlIdentical (" https://example.com" , " https://example.com" ));
103- QVERIFY (urlTools ()-> isUrlIdentical (" https://example.com" , " https://example.com " ));
104- QVERIFY (!urlTools ()-> isUrlIdentical (" https://example.com" , " https://example2.com" ));
105- QVERIFY (!urlTools ()-> isUrlIdentical (" https://example.com/" , " https://example.com/#login" ));
106- QVERIFY (urlTools ()-> isUrlIdentical (" https://example.com" , " https://example.com/" ));
107- QVERIFY (urlTools ()-> isUrlIdentical (" https://example.com/" , " https://example.com" ));
108- QVERIFY (urlTools ()-> isUrlIdentical (" https://example.com/ " , " https://example.com" ));
109- QVERIFY (!urlTools ()-> isUrlIdentical (" https://example.com/" , " example.com" ));
110- QVERIFY (urlTools ()-> isUrlIdentical (" https://example.com/path/to/nowhere" , " https://example.com/path/to/nowhere/" ));
111- QVERIFY (!urlTools ()-> isUrlIdentical (" https://example.com/" , " ://example.com/" ));
112- QVERIFY (urlTools ()-> isUrlIdentical (" ftp://127.0.0.1/" , " ftp://127.0.0.1" ));
93+ QVERIFY (UrlTools:: isUrlIdentical (" https://example.com" , " https://example.com" ));
94+ QVERIFY (UrlTools:: isUrlIdentical (" https://example.com" , " https://example.com " ));
95+ QVERIFY (!UrlTools:: isUrlIdentical (" https://example.com" , " https://example2.com" ));
96+ QVERIFY (!UrlTools:: isUrlIdentical (" https://example.com/" , " https://example.com/#login" ));
97+ QVERIFY (UrlTools:: isUrlIdentical (" https://example.com" , " https://example.com/" ));
98+ QVERIFY (UrlTools:: isUrlIdentical (" https://example.com/" , " https://example.com" ));
99+ QVERIFY (UrlTools:: isUrlIdentical (" https://example.com/ " , " https://example.com" ));
100+ QVERIFY (!UrlTools:: isUrlIdentical (" https://example.com/" , " example.com" ));
101+ QVERIFY (UrlTools:: isUrlIdentical (" https://example.com/path/to/nowhere" , " https://example.com/path/to/nowhere/" ));
102+ QVERIFY (!UrlTools:: isUrlIdentical (" https://example.com/" , " ://example.com/" ));
103+ QVERIFY (UrlTools:: isUrlIdentical (" ftp://127.0.0.1/" , " ftp://127.0.0.1" ));
113104}
114105
115106void TestUrlTools::testIsUrlValid ()
@@ -130,7 +121,7 @@ void TestUrlTools::testIsUrlValid()
130121 QHashIterator<QString, bool > i (urls);
131122 while (i.hasNext ()) {
132123 i.next ();
133- QCOMPARE (urlTools ()-> isUrlValid (i.key ()), i.value ());
124+ QCOMPARE (UrlTools:: isUrlValid (i.key ()), i.value ());
134125 }
135126}
136127
@@ -165,13 +156,13 @@ void TestUrlTools::testIsUrlValidWithLooseComparison()
165156 QHashIterator<QString, bool > i (urls);
166157 while (i.hasNext ()) {
167158 i.next ();
168- QCOMPARE (urlTools ()-> isUrlValid (i.key (), true ), i.value ());
159+ QCOMPARE (UrlTools:: isUrlValid (i.key (), true ), i.value ());
169160 }
170161}
171162
172163void TestUrlTools::testDomainHasIllegalCharacters ()
173164{
174- QVERIFY (!urlTools ()-> domainHasIllegalCharacters (" example.com" ));
175- QVERIFY (urlTools ()-> domainHasIllegalCharacters (" domain has spaces.com" ));
176- QVERIFY (urlTools ()-> domainHasIllegalCharacters (" example#|.com" ));
165+ QVERIFY (!UrlTools:: domainHasIllegalCharacters (" example.com" ));
166+ QVERIFY (UrlTools:: domainHasIllegalCharacters (" domain has spaces.com" ));
167+ QVERIFY (UrlTools:: domainHasIllegalCharacters (" example#|.com" ));
177168}
0 commit comments