summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qurl
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2016-11-21 11:38:43 +0100
committerAndy Shaw <andy.shaw@qt.io>2016-11-22 07:05:30 +0000
commit3cd457bdad6eee4a703ef9773b80165a272fbdc7 (patch)
treec0112073c97b269e642a03653d408e19a65e0dec /tests/auto/corelib/io/qurl
parent9f17c245893e296d5c92ed1ef1e5d08896b469b1 (diff)
Handle RemovePath correctly when calling matches()
Change-Id: Ied324a537df127e676fad26b42e658a9d5aeec9b Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'tests/auto/corelib/io/qurl')
-rw-r--r--tests/auto/corelib/io/qurl/tst_qurl.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp
index 8f99047df3..670b72acc8 100644
--- a/tests/auto/corelib/io/qurl/tst_qurl.cpp
+++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp
@@ -182,6 +182,8 @@ private slots:
void streaming();
void detach();
void testThreading();
+ void matches_data();
+ void matches();
private:
void testThreadingHelper();
@@ -4023,6 +4025,54 @@ void tst_QUrl::testThreading()
delete s_urlStorage;
}
+void tst_QUrl::matches_data()
+{
+ QTest::addColumn<QString>("urlStrOne");
+ QTest::addColumn<QString>("urlStrTwo");
+ QTest::addColumn<uint>("options");
+ QTest::addColumn<bool>("matches");
+
+ QTest::newRow("matchingString-none") << "http://www.website.com/directory/?#ref"
+ << "http://www.website.com/directory/?#ref"
+ << uint(QUrl::None) << true;
+ QTest::newRow("nonMatchingString-none") << "http://www.website.com/directory/?#ref"
+ << "http://www.nomatch.com/directory/?#ref"
+ << uint(QUrl::None) << false;
+ QTest::newRow("matchingHost-removePath") << "http://www.website.com/directory"
+ << "http://www.website.com/differentdir"
+ << uint(QUrl::RemovePath) << true;
+ QTest::newRow("nonMatchingHost-removePath") << "http://www.website.com/directory"
+ << "http://www.different.com/differentdir"
+ << uint(QUrl::RemovePath) << false;
+ QTest::newRow("matchingHost-removePathAuthority") << "http://user:pass@www.website.com/directory"
+ << "http://www.website.com/differentdir"
+ << uint(QUrl::RemovePath | QUrl::RemoveAuthority)
+ << true;
+ QTest::newRow("nonMatchingHost-removePathAuthority") << "http://user:pass@www.website.com/directory"
+ << "http://user:pass@www.different.com/differentdir"
+ << uint(QUrl::RemovePath | QUrl::RemoveAuthority)
+ << true;
+ QTest::newRow("matchingHostAuthority-removePathAuthority")
+ << "http://user:pass@www.website.com/directory" << "http://www.website.com/differentdir"
+ << uint(QUrl::RemovePath | QUrl::RemoveAuthority) << true;
+ QTest::newRow("nonMatchingAuthority-removePathAuthority")
+ << "http://user:pass@www.website.com/directory"
+ << "http://otheruser:otherpass@www.website.com/directory"
+ << uint(QUrl::RemovePath | QUrl::RemoveAuthority) << true;
+}
+
+void tst_QUrl::matches()
+{
+ QFETCH(QString, urlStrOne);
+ QFETCH(QString, urlStrTwo);
+ QFETCH(uint, options);
+ QFETCH(bool, matches);
+
+ QUrl urlOne(urlStrOne);
+ QUrl urlTwo(urlStrTwo);
+ QCOMPARE(urlOne.matches(urlTwo, QUrl::FormattingOptions(options)), matches);
+}
+
QTEST_MAIN(tst_QUrl)
#include "tst_qurl.moc"