tests/auto/qurl/tst_qurl.cpp
changeset 18 2f34d5167611
parent 3 41300fa6a67c
child 19 fcece45ef507
--- a/tests/auto/qurl/tst_qurl.cpp	Tue Feb 02 00:43:10 2010 +0200
+++ b/tests/auto/qurl/tst_qurl.cpp	Fri Apr 16 15:50:13 2010 +0300
@@ -1,6 +1,6 @@
 /****************************************************************************
 **
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
 ** All rights reserved.
 ** Contact: Nokia Corporation (qt-info@nokia.com)
 **
@@ -165,6 +165,8 @@
     void ace_testsuite();
     void std3violations_data();
     void std3violations();
+    void std3deviations_data();
+    void std3deviations();
     void tldRestrictions_data();
     void tldRestrictions();
     void emptyQueryOrFragment();
@@ -1682,6 +1684,12 @@
 			<< QByteArray("//qt.nokia.com/index.html");
     QTest::newRow("data2") << QString::fromLatin1("file") << n << n << n << -1 << QString::fromLatin1("/root") << QByteArray()
                         << n << QString::fromLatin1("file:///root") << QByteArray("file:///root");
+    QTest::newRow("userAndPass") << QString::fromLatin1("http") << QString::fromLatin1("dfaure") << QString::fromLatin1("kde")
+                                 << "kde.org" << 443 << QString::fromLatin1("/") << QByteArray() << n
+                                 << QString::fromLatin1("http://dfaure:kde@kde.org:443/") << QByteArray("http://dfaure:kde@kde.org:443/");
+    QTest::newRow("PassWithoutUser") << QString::fromLatin1("http") << n << QString::fromLatin1("kde")
+                                     << "kde.org" << 443 << QString::fromLatin1("/") << QByteArray() << n
+                                     << QString::fromLatin1("http://:kde@kde.org:443/") << QByteArray("http://:kde@kde.org:443/");
 }
 
 void tst_QUrl::toString_constructed()
@@ -1717,6 +1725,7 @@
 
     QVERIFY(url.isValid());
     QCOMPARE(url.toString(), asString);
+    QCOMPARE(QString::fromLatin1(url.toEncoded()), QString::fromLatin1(asEncoded)); // readable in case of differences
     QCOMPARE(url.toEncoded(), asEncoded);
 }
 
@@ -1823,7 +1832,7 @@
     QTest::addColumn<QString>("res");
 
     //next we fill it with data
-    QTest::newRow( "data0" )  << QString("Makefile") << QString("Makefile"); // nolonger add file by defualt
+    QTest::newRow( "data0" )  << QString("Makefile") << QString("Makefile"); // nolonger add file by default
     QTest::newRow( "data1" )  << QString("Makefile") << QString("Makefile");
     QTest::newRow( "data2" )  << QString("ftp://ftp.qt.nokia.com/qt/INSTALL") << QString("ftp://ftp.qt.nokia.com/qt/INSTALL");
     QTest::newRow( "data3" )  << QString("ftp://ftp.qt.nokia.com/qt/INSTALL") << QString("ftp://ftp.qt.nokia.com/qt/INSTALL");
@@ -3231,6 +3240,8 @@
     QTest::newRow("bang") << "foo!" << false;
     QTest::newRow("plus") << "foo+bar" << false;
     QTest::newRow("dot") << "foo.bar";
+    QTest::newRow("startingdot") << ".bar" << false;
+    QTest::newRow("startingdot2") << ".example.com" << false;
     QTest::newRow("slash") << "foo/bar" << true;
     QTest::newRow("colon") << "foo:80" << true;
     QTest::newRow("question") << "foo?bar" << true;
@@ -3275,6 +3286,24 @@
     QVERIFY(!url.isValid());
 }
 
+void tst_QUrl::std3deviations_data()
+{
+    QTest::addColumn<QString>("source");
+
+    QTest::newRow("ending-dot") << "example.com.";
+    QTest::newRow("ending-dot3002") << QString("example.com") + QChar(0x3002);
+}
+
+void tst_QUrl::std3deviations()
+{
+    QFETCH(QString, source);
+    QVERIFY(!QUrl::toAce(source).isEmpty());
+
+    QUrl url;
+    url.setHost(source);
+    QVERIFY(!url.host().isEmpty());
+}
+
 void tst_QUrl::tldRestrictions_data()
 {
     QTest::addColumn<QString>("tld");