tests/auto/qurl/tst_qurl.cpp
changeset 29 b72c6db6890b
parent 25 e24348a560a6
child 30 5dc02b23752f
--- a/tests/auto/qurl/tst_qurl.cpp	Fri Jun 11 14:24:45 2010 +0300
+++ b/tests/auto/qurl/tst_qurl.cpp	Wed Jun 23 19:07:03 2010 +0300
@@ -1409,7 +1409,7 @@
 void tst_QUrl::i18n_data()
 {
     QTest::addColumn<QString>("input");
-    QTest::addColumn<QByteArray>("punyOutput"); 
+    QTest::addColumn<QByteArray>("punyOutput");
 
     QTest::newRow("øl") << QString::fromLatin1("http://ole:passord@www.øl.no/index.html?ole=æsemann&ilder gud=hei#top")
                      <<          QByteArray("http://ole:passord@www.xn--l-4ga.no/index.html?ole=%C3%A6semann&ilder%20gud=hei#top");
@@ -1631,6 +1631,10 @@
     QTest::newRow("nopath_task31320") << QString::fromLatin1("host://protocol")
                                    << uint(QUrl::None)
                                    << QString::fromLatin1("host://protocol");
+
+    QTest::newRow("underscore_QTBUG-7434") << QString::fromLatin1("http://foo_bar.host.com/rss.php")
+                                   << uint(QUrl::None)
+                                   << QString::fromLatin1("http://foo_bar.host.com/rss.php");
 }
 
 void tst_QUrl::toString()
@@ -2160,25 +2164,25 @@
     QTest::addColumn<QByteArray>("includeInEncoding");
 
     QTest::newRow("test_01") << QString::fromLatin1("abcdevghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678-._~")
-                          << QByteArray("abcdevghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678-._~") 
+                          << QByteArray("abcdevghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678-._~")
                           << QByteArray("")
                           << QByteArray("");
     QTest::newRow("test_02") << QString::fromLatin1("{\t\n\r^\"abc}")
-                          << QByteArray("%7B%09%0A%0D%5E%22abc%7D") 
+                          << QByteArray("%7B%09%0A%0D%5E%22abc%7D")
                           << QByteArray("")
                           << QByteArray("");
     QTest::newRow("test_03") << QString::fromLatin1("://?#[]@!$&'()*+,;=")
-                          << QByteArray("%3A%2F%2F%3F%23%5B%5D%40%21%24%26%27%28%29%2A%2B%2C%3B%3D") 
+                          << QByteArray("%3A%2F%2F%3F%23%5B%5D%40%21%24%26%27%28%29%2A%2B%2C%3B%3D")
                           << QByteArray("")
                           << QByteArray("");
     QTest::newRow("test_04") << QString::fromLatin1("://?#[]@!$&'()*+,;=")
-                          << QByteArray("%3A%2F%2F%3F%23%5B%5D%40!$&'()*+,;=") 
+                          << QByteArray("%3A%2F%2F%3F%23%5B%5D%40!$&'()*+,;=")
                           << QByteArray("!$&'()*+,;=")
                           << QByteArray("");
     QTest::newRow("test_05") << QString::fromLatin1("abcd")
                           << QByteArray("a%62%63d")
                           << QByteArray("")
-                          << QByteArray("bc");                          
+                          << QByteArray("bc");
 }
 
 void tst_QUrl::toPercentEncoding()
@@ -2188,7 +2192,7 @@
     QFETCH(QByteArray, excludeInEncoding);
     QFETCH(QByteArray, includeInEncoding);
 
-    QByteArray encodedUrl = QUrl::toPercentEncoding(original, excludeInEncoding, includeInEncoding); 
+    QByteArray encodedUrl = QUrl::toPercentEncoding(original, excludeInEncoding, includeInEncoding);
     QCOMPARE(encodedUrl.constData(), encoded.constData());
     QCOMPARE(original, QUrl::fromPercentEncoding(encodedUrl));
 }
@@ -2456,6 +2460,8 @@
         QUrl url = QUrl::fromEncoded("http://strange<username>@ok-hostname/", QUrl::StrictMode);
         QVERIFY(!url.isValid());
         // < and > are not allowed in userinfo in strict mode
+        url.setUserName("normal_username");
+        QVERIFY(url.isValid());
     }
     {
         QUrl url = QUrl::fromEncoded("http://strange<username>@ok-hostname/");
@@ -2466,7 +2472,18 @@
         QUrl url = QUrl::fromEncoded("http://strange;hostname/here");
         QVERIFY(!url.isValid());
         QCOMPARE(url.path(), QString("/here"));
+        url.setAuthority("foobar@bar");
+        QVERIFY(url.isValid());
     }
+
+    {
+        QUrl url = QUrl::fromEncoded("foo://stuff;1/g");
+        QVERIFY(!url.isValid());
+        QCOMPARE(url.path(), QString("/g"));
+        url.setHost("stuff-1");
+        QVERIFY(url.isValid());
+    }
+
 }
 
 void tst_QUrl::schemeValidator_data()
@@ -3269,7 +3286,6 @@
     QTest::newRow("question") << "foo?bar" << true;
     QTest::newRow("at") << "foo@bar" << true;
     QTest::newRow("backslash") << "foo\\bar" << false;
-    QTest::newRow("underline") << "foo_bar" << false;
 
     // these characters are transformed by NFKC to non-LDH characters
     QTest::newRow("dot-like") << QString::fromUtf8("foo\342\200\244bar") << false;  // U+2024 ONE DOT LEADER
@@ -3314,6 +3330,7 @@
 
     QTest::newRow("ending-dot") << "example.com.";
     QTest::newRow("ending-dot3002") << QString("example.com") + QChar(0x3002);
+    QTest::newRow("underline") << "foo_bar";  //QTBUG-7434
 }
 
 void tst_QUrl::std3deviations()