summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDavid Faure <faure@kde.org>2012-05-03 18:49:46 +0200
committerQt by Nokia <qt-info@nokia.com>2012-05-04 13:03:35 +0200
commit7c717e56f51e7e8b1ab756f4b2b9717dadb1d82c (patch)
tree6573bbadbf3961d203280a480aad58fdcc90df7c /tests
parent5190beae8166e615d2f910109cf081505ebe6807 (diff)
Fix QUrl::toString(StripTrailingSlash) to not turn file:/// into file:
It should only strip one slash (as the name indicates), and not if the path is just "/". Change-Id: I133a81977241de77a49d1d1559143d30e0bd52f8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/io/qurl/tst_qurl.cpp28
1 files changed, 18 insertions, 10 deletions
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp
index 608bdfb78b..dc799b47e5 100644
--- a/tests/auto/corelib/io/qurl/tst_qurl.cpp
+++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp
@@ -140,6 +140,7 @@ private slots:
void setEncodedFragment_data();
void setEncodedFragment();
void fromEncoded();
+ void stripTrailingSlash_data();
void stripTrailingSlash();
void hosts_data();
void hosts();
@@ -2246,18 +2247,25 @@ void tst_QUrl::fromEncoded()
QCOMPARE(qurl_newline_1.toEncoded().constData(), "http://www.foo.bar/foo/bar%0Agnork");
}
+void tst_QUrl::stripTrailingSlash_data()
+{
+ QTest::addColumn<QString>("url");
+ QTest::addColumn<QString>("expected");
+
+ QTest::newRow("ftp no slash") << "ftp://ftp.de.kde.org/dir" << "ftp://ftp.de.kde.org/dir";
+ QTest::newRow("ftp slash") << "ftp://ftp.de.kde.org/dir/" << "ftp://ftp.de.kde.org/dir";
+ QTest::newRow("file slash") << "file:///dir/" << "file:///dir";
+ QTest::newRow("file no slash") << "file:///dir/" << "file:///dir";
+ QTest::newRow("file root") << "file:///" << "file:///";
+}
+
void tst_QUrl::stripTrailingSlash()
{
- QUrl u1( "ftp://ftp.de.kde.org/dir" );
- QUrl u2( "ftp://ftp.de.kde.org/dir/" );
- QUrl::FormattingOptions options = QUrl::None;
- options |= QUrl::StripTrailingSlash;
- QString str1 = u1.toString(options);
- QString str2 = u2.toString(options);
- QCOMPARE( str1, u1.toString() );
- QCOMPARE( str2, u1.toString() );
- bool same = str1 == str2;
- QVERIFY( same );
+ QFETCH(QString, url);
+ QFETCH(QString, expected);
+
+ QUrl u(url);
+ QCOMPARE(u.toString(QUrl::StripTrailingSlash), expected);
}
void tst_QUrl::hosts_data()