diff options
author | Jason McDonald <jason.mcdonald@nokia.com> | 2011-11-07 19:19:27 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-11-10 04:42:45 +0100 |
commit | 8e11f7c93a1f7df0d10e2f851283c825ca39b75b (patch) | |
tree | 6f02b39217acd9fb9c033fbe908b8ebb1859896a /tests/auto/corelib/io | |
parent | 2cd47107155fc251747028b9b0ae6d2c9e69e06c (diff) |
Cleanup corelib autotests
Remove literal tabs.
Change-Id: I210a0259773cceb20d35ebc80b889e3ebb88b540
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Diffstat (limited to 'tests/auto/corelib/io')
-rw-r--r-- | tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp | 133 | ||||
-rw-r--r-- | tests/auto/corelib/io/qfile/tst_qfile.cpp | 33 | ||||
-rw-r--r-- | tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp | 88 | ||||
-rw-r--r-- | tests/auto/corelib/io/qsettings/tst_qsettings.cpp | 28 | ||||
-rw-r--r-- | tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp | 60 | ||||
-rw-r--r-- | tests/auto/corelib/io/qurl/tst_qurl.cpp | 235 |
6 files changed, 286 insertions, 291 deletions
diff --git a/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp b/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp index 832d7ee063..c65da128bf 100644 --- a/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp +++ b/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp @@ -203,72 +203,73 @@ void tst_QBuffer::writeBlock_data() QTest::addColumn<QString>("str"); QTest::newRow( "small_bytearray" ) << QString("Test"); - QTest::newRow( "large_bytearray" ) << QString("The QBuffer class is an I/O device that operates on a QByteArray.\n" - "QBuffer is used to read and write to a memory buffer. It is normally " - "used with a QTextStream or a QDataStream. QBuffer has an associated " - "QByteArray which holds the buffer data. The size() of the buffer is " - "automatically adjusted as data is written.\n" - "The constructor QBuffer(QByteArray) creates a QBuffer using an existing " - "byte array. The byte array can also be set with setBuffer(). Writing to " - "the QBuffer will modify the original byte array because QByteArray is " - "explicitly shared.\n" - "Use open() to open the buffer before use and to set the mode (read-only, " - "write-only, etc.). close() closes the buffer. The buffer must be closed " - "before reopening or calling setBuffer().\n" - "A common way to use QBuffer is through QDataStream or QTextStream, which " - "have constructors that take a QBuffer parameter. For convenience, there " - "are also QDataStream and QTextStream constructors that take a QByteArray " - "parameter. These constructors create and open an internal QBuffer.\n" - "Note that QTextStream can also operate on a QString (a Unicode string); a " - "QBuffer cannot.\n" - "You can also use QBuffer directly through the standard QIODevice functions " - "readBlock(), writeBlock() readLine(), at(), getch(), putch() and ungetch().\n" - "See also QFile, QDataStream, QTextStream, QByteArray, Shared Classes, Collection " - "Classes and Input/Output and Networking.\n\n" - "The QBuffer class is an I/O device that operates on a QByteArray.\n" - "QBuffer is used to read and write to a memory buffer. It is normally " - "used with a QTextStream or a QDataStream. QBuffer has an associated " - "QByteArray which holds the buffer data. The size() of the buffer is " - "automatically adjusted as data is written.\n" - "The constructor QBuffer(QByteArray) creates a QBuffer using an existing " - "byte array. The byte array can also be set with setBuffer(). Writing to " - "the QBuffer will modify the original byte array because QByteArray is " - "explicitly shared.\n" - "Use open() to open the buffer before use and to set the mode (read-only, " - "write-only, etc.). close() closes the buffer. The buffer must be closed " - "before reopening or calling setBuffer().\n" - "A common way to use QBuffer is through QDataStream or QTextStream, which " - "have constructors that take a QBuffer parameter. For convenience, there " - "are also QDataStream and QTextStream constructors that take a QByteArray " - "parameter. These constructors create and open an internal QBuffer.\n" - "Note that QTextStream can also operate on a QString (a Unicode string); a " - "QBuffer cannot.\n" - "You can also use QBuffer directly through the standard QIODevice functions " - "readBlock(), writeBlock() readLine(), at(), getch(), putch() and ungetch().\n" - "See also QFile, QDataStream, QTextStream, QByteArray, Shared Classes, Collection " - "Classes and Input/Output and Networking.\n\n" - "The QBuffer class is an I/O device that operates on a QByteArray.\n" - "QBuffer is used to read and write to a memory buffer. It is normally " - "used with a QTextStream or a QDataStream. QBuffer has an associated " - "QByteArray which holds the buffer data. The size() of the buffer is " - "automatically adjusted as data is written.\n" - "The constructor QBuffer(QByteArray) creates a QBuffer using an existing " - "byte array. The byte array can also be set with setBuffer(). Writing to " - "the QBuffer will modify the original byte array because QByteArray is " - "explicitly shared.\n" - "Use open() to open the buffer before use and to set the mode (read-only, " - "write-only, etc.). close() closes the buffer. The buffer must be closed " - "before reopening or calling setBuffer().\n" - "A common way to use QBuffer is through QDataStream or QTextStream, which " - "have constructors that take a QBuffer parameter. For convenience, there " - "are also QDataStream and QTextStream constructors that take a QByteArray " - "parameter. These constructors create and open an internal QBuffer.\n" - "Note that QTextStream can also operate on a QString (a Unicode string); a " - "QBuffer cannot.\n" - "You can also use QBuffer directly through the standard QIODevice functions " - "readBlock(), writeBlock() readLine(), at(), getch(), putch() and ungetch().\n" - "See also QFile, QDataStream, QTextStream, QByteArray, Shared Classes, Collection " - "Classes and Input/Output and Networking."); + QTest::newRow( "large_bytearray" ) << QString( + "The QBuffer class is an I/O device that operates on a QByteArray.\n" + "QBuffer is used to read and write to a memory buffer. It is normally " + "used with a QTextStream or a QDataStream. QBuffer has an associated " + "QByteArray which holds the buffer data. The size() of the buffer is " + "automatically adjusted as data is written.\n" + "The constructor QBuffer(QByteArray) creates a QBuffer using an existing " + "byte array. The byte array can also be set with setBuffer(). Writing to " + "the QBuffer will modify the original byte array because QByteArray is " + "explicitly shared.\n" + "Use open() to open the buffer before use and to set the mode (read-only, " + "write-only, etc.). close() closes the buffer. The buffer must be closed " + "before reopening or calling setBuffer().\n" + "A common way to use QBuffer is through QDataStream or QTextStream, which " + "have constructors that take a QBuffer parameter. For convenience, there " + "are also QDataStream and QTextStream constructors that take a QByteArray " + "parameter. These constructors create and open an internal QBuffer.\n" + "Note that QTextStream can also operate on a QString (a Unicode string); a " + "QBuffer cannot.\n" + "You can also use QBuffer directly through the standard QIODevice functions " + "readBlock(), writeBlock() readLine(), at(), getch(), putch() and ungetch().\n" + "See also QFile, QDataStream, QTextStream, QByteArray, Shared Classes, Collection " + "Classes and Input/Output and Networking.\n\n" + "The QBuffer class is an I/O device that operates on a QByteArray.\n" + "QBuffer is used to read and write to a memory buffer. It is normally " + "used with a QTextStream or a QDataStream. QBuffer has an associated " + "QByteArray which holds the buffer data. The size() of the buffer is " + "automatically adjusted as data is written.\n" + "The constructor QBuffer(QByteArray) creates a QBuffer using an existing " + "byte array. The byte array can also be set with setBuffer(). Writing to " + "the QBuffer will modify the original byte array because QByteArray is " + "explicitly shared.\n" + "Use open() to open the buffer before use and to set the mode (read-only, " + "write-only, etc.). close() closes the buffer. The buffer must be closed " + "before reopening or calling setBuffer().\n" + "A common way to use QBuffer is through QDataStream or QTextStream, which " + "have constructors that take a QBuffer parameter. For convenience, there " + "are also QDataStream and QTextStream constructors that take a QByteArray " + "parameter. These constructors create and open an internal QBuffer.\n" + "Note that QTextStream can also operate on a QString (a Unicode string); a " + "QBuffer cannot.\n" + "You can also use QBuffer directly through the standard QIODevice functions " + "readBlock(), writeBlock() readLine(), at(), getch(), putch() and ungetch().\n" + "See also QFile, QDataStream, QTextStream, QByteArray, Shared Classes, Collection " + "Classes and Input/Output and Networking.\n\n" + "The QBuffer class is an I/O device that operates on a QByteArray.\n" + "QBuffer is used to read and write to a memory buffer. It is normally " + "used with a QTextStream or a QDataStream. QBuffer has an associated " + "QByteArray which holds the buffer data. The size() of the buffer is " + "automatically adjusted as data is written.\n" + "The constructor QBuffer(QByteArray) creates a QBuffer using an existing " + "byte array. The byte array can also be set with setBuffer(). Writing to " + "the QBuffer will modify the original byte array because QByteArray is " + "explicitly shared.\n" + "Use open() to open the buffer before use and to set the mode (read-only, " + "write-only, etc.). close() closes the buffer. The buffer must be closed " + "before reopening or calling setBuffer().\n" + "A common way to use QBuffer is through QDataStream or QTextStream, which " + "have constructors that take a QBuffer parameter. For convenience, there " + "are also QDataStream and QTextStream constructors that take a QByteArray " + "parameter. These constructors create and open an internal QBuffer.\n" + "Note that QTextStream can also operate on a QString (a Unicode string); a " + "QBuffer cannot.\n" + "You can also use QBuffer directly through the standard QIODevice functions " + "readBlock(), writeBlock() readLine(), at(), getch(), putch() and ungetch().\n" + "See also QFile, QDataStream, QTextStream, QByteArray, Shared Classes, Collection " + "Classes and Input/Output and Networking."); } void tst_QBuffer::writeBlock() diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index a398140061..7c095f329a 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -644,7 +644,7 @@ void tst_QFile::setSize() QCOMPARE(c, 'a'); QCOMPARE(f.size(), (qlonglong)1); - bool ok = f.resize(99); + bool ok = f.resize(99); QVERIFY(ok); QCOMPARE(f.size(), (qlonglong)99); @@ -1492,19 +1492,19 @@ void tst_QFile::tailFile() void tst_QFile::flush() { - QString fileName("stdfile.txt"); + QString fileName("stdfile.txt"); - QFile::remove(fileName); + QFile::remove(fileName); - { - QFile file(fileName); - QVERIFY(file.open(QFile::WriteOnly)); - QCOMPARE(file.write("abc", 3),qint64(3)); - } + { + QFile file(fileName); + QVERIFY(file.open(QFile::WriteOnly)); + QCOMPARE(file.write("abc", 3),qint64(3)); + } - { - QFile file(fileName); - QVERIFY(file.open(QFile::WriteOnly | QFile::Append)); + { + QFile file(fileName); + QVERIFY(file.open(QFile::WriteOnly | QFile::Append)); QCOMPARE(file.pos(), qlonglong(3)); QCOMPARE(file.write("def", 3), qlonglong(3)); QCOMPARE(file.pos(), qlonglong(6)); @@ -1516,7 +1516,7 @@ void tst_QFile::flush() QCOMPARE(file.readAll(), QByteArray("abcdef")); } - QFile::remove(fileName); + QFile::remove(fileName); } void tst_QFile::bufferedRead() @@ -1529,7 +1529,7 @@ void tst_QFile::bufferedRead() file.close(); #if defined(Q_OS_WINCE) - FILE *stdFile = fopen((QCoreApplication::applicationDirPath() + "/stdfile.txt").toAscii() , "r"); + FILE *stdFile = fopen((QCoreApplication::applicationDirPath() + "/stdfile.txt").toAscii() , "r"); #else FILE *stdFile = fopen("stdfile.txt", "r"); #endif @@ -2281,7 +2281,7 @@ void tst_QFile::virtualFile() void tst_QFile::textFile() { #if defined(Q_OS_WINCE) - FILE *fs = ::fopen((QCoreApplication::applicationDirPath() + "/writeabletextfile").toAscii() , "wt"); + FILE *fs = ::fopen((QCoreApplication::applicationDirPath() + "/writeabletextfile").toAscii() , "wt"); #elif defined(Q_OS_WIN) FILE *fs = ::fopen("writeabletextfile", "wt"); #else @@ -2787,8 +2787,7 @@ void tst_QFile::map() QVERIFY(file.open(QFile::ReadWrite)); memory = file.map(offset, size); if (error != QFile::NoError) { - - QVERIFY(file.error() != QFile::NoError); + QVERIFY(file.error() != QFile::NoError); return; } @@ -2909,7 +2908,7 @@ void tst_QFile::mapOpenMode() if (QFile::exists(fileName)) { QVERIFY(QFile::setPermissions(fileName, QFile::WriteOwner | QFile::ReadOwner | QFile::WriteUser | QFile::ReadUser)); - QFile::remove(fileName); + QFile::remove(fileName); } QFile file(fileName); diff --git a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp index 84431b2f9e..d3a8e0fd60 100644 --- a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp +++ b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp @@ -250,10 +250,10 @@ void tst_QIODevice::unget() for (int i = 0; i < 2; ++i) { QTcpSocket socket; - QIODevice *dev; - QByteArray result; - const char *lineResult; - if (i == 0) { + QIODevice *dev; + QByteArray result; + const char *lineResult; + if (i == 0) { dev = &buffer; result = QByteArray("ZXCV"); lineResult = "ZXCV"; @@ -264,21 +264,21 @@ void tst_QIODevice::unget() dev = &socket; result = QByteArray("HTTP"); lineResult = "Date"; - } - char ch, ch2; - dev->seek(0); - dev->getChar(&ch); - dev->ungetChar(ch); - QCOMPARE(dev->peek(4), result); - dev->getChar(&ch); - dev->getChar(&ch2); - dev->ungetChar(ch2); - dev->ungetChar(ch); - QCOMPARE(dev->read(1), result.left(1)); - QCOMPARE(dev->read(3), result.right(3)); + } + char ch, ch2; + dev->seek(0); + dev->getChar(&ch); + dev->ungetChar(ch); + QCOMPARE(dev->peek(4), result); + dev->getChar(&ch); + dev->getChar(&ch2); + dev->ungetChar(ch2); + dev->ungetChar(ch); + QCOMPARE(dev->read(1), result.left(1)); + QCOMPARE(dev->read(3), result.right(3)); if (i == 0) - dev->seek(0); + dev->seek(0); else dev->readLine(); dev->getChar(&ch); @@ -300,33 +300,33 @@ void tst_QIODevice::peek() QFile file("peektestfile"); for (int i = 0; i < 2; ++i) { - QIODevice *device = i ? (QIODevice *)&file : (QIODevice *)&buffer; - - device->open(QBuffer::ReadWrite); - device->write("ZXCV"); - - device->seek(0); - QCOMPARE(device->peek(4), QByteArray("ZXCV")); - QCOMPARE(device->pos(), qint64(0)); - device->write("ABCDE"); - device->seek(3); - QCOMPARE(device->peek(1), QByteArray("D")); - QCOMPARE(device->peek(5), QByteArray("DE")); - device->seek(0); - QCOMPARE(device->read(4), QByteArray("ABCD")); - QCOMPARE(device->pos(), qint64(4)); - - device->seek(0); - device->write("ZXCV"); - device->seek(0); - char buf[5]; - buf[4] = 0; - device->peek(buf, 4); - QCOMPARE(static_cast<const char *>(buf), "ZXCV"); - QCOMPARE(device->pos(), qint64(0)); - device->read(buf, 4); - QCOMPARE(static_cast<const char *>(buf), "ZXCV"); - QCOMPARE(device->pos(), qint64(4)); + QIODevice *device = i ? (QIODevice *)&file : (QIODevice *)&buffer; + + device->open(QBuffer::ReadWrite); + device->write("ZXCV"); + + device->seek(0); + QCOMPARE(device->peek(4), QByteArray("ZXCV")); + QCOMPARE(device->pos(), qint64(0)); + device->write("ABCDE"); + device->seek(3); + QCOMPARE(device->peek(1), QByteArray("D")); + QCOMPARE(device->peek(5), QByteArray("DE")); + device->seek(0); + QCOMPARE(device->read(4), QByteArray("ABCD")); + QCOMPARE(device->pos(), qint64(4)); + + device->seek(0); + device->write("ZXCV"); + device->seek(0); + char buf[5]; + buf[4] = 0; + device->peek(buf, 4); + QCOMPARE(static_cast<const char *>(buf), "ZXCV"); + QCOMPARE(device->pos(), qint64(0)); + device->read(buf, 4); + QCOMPARE(static_cast<const char *>(buf), "ZXCV"); + QCOMPARE(device->pos(), qint64(4)); } QFile::remove("peektestfile"); } diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp index eabd4cd761..c9b9183daf 100644 --- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp +++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp @@ -203,7 +203,7 @@ static QString settingsPath(const char *path = "") // Temporary path for files that are specified explictly in the constructor. QString tempPath = QDir::tempPath(); if (tempPath.endsWith("/")) - tempPath.truncate(tempPath.size() - 1); + tempPath.truncate(tempPath.size() - 1); return QDir::toNativeSeparators(tempPath + "/tst_QSettings/" + QLatin1String(path)); } @@ -309,9 +309,9 @@ void tst_QSettings::init() removePath(settingsPath()); #else if (QSysInfo::windowsVersion() & QSysInfo::WV_NT_based) - system(QString("rmdir /Q /S %1").arg(settingsPath()).toLatin1()); - else - system(QString("deltree /Y %1").arg(settingsPath()).toLatin1()); + system(QString("rmdir /Q /S %1").arg(settingsPath()).toLatin1()); + else + system(QString("deltree /Y %1").arg(settingsPath()).toLatin1()); #endif } #elif defined(Q_OS_DARWIN) @@ -812,16 +812,16 @@ void tst_QSettings::testIniParsing() QSettings settings(settingsPath("someDir/someSettings.ini"), QSettings::IniFormat); if ( settings.status() == QSettings::NoError ) { // else no point proceeding - QVariant v = settings.value(key); - QVERIFY(v.canConvert(expect.type())); - // check some types so as to give prettier error messages - if ( v.type() == QVariant::String ) { - QCOMPARE(v.toString(), expect.toString()); - } else if ( v.type() == QVariant::Int ) { - QCOMPARE(v.toInt(), expect.toInt()); - } else { - QCOMPARE(v, expect); - } + QVariant v = settings.value(key); + QVERIFY(v.canConvert(expect.type())); + // check some types so as to give prettier error messages + if ( v.type() == QVariant::String ) { + QCOMPARE(v.toString(), expect.toString()); + } else if ( v.type() == QVariant::Int ) { + QCOMPARE(v.toInt(), expect.toInt()); + } else { + QCOMPARE(v, expect); + } } QCOMPARE(settings.status(), status); diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp index b2b0f57240..dd8b7829ff 100644 --- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp +++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp @@ -224,38 +224,36 @@ void tst_QTemporaryFile::fileNameIsEmpty() void tst_QTemporaryFile::autoRemove() { - // Test auto remove - QString fileName; - { - QTemporaryFile file("tempXXXXXX"); - file.setAutoRemove(true); - QVERIFY(file.open()); - fileName = file.fileName(); - file.close(); - } - QVERIFY(!QFile::exists(fileName)); - - // Test if disabling auto remove works. - { - QTemporaryFile file("tempXXXXXX"); - file.setAutoRemove(false); - QVERIFY(file.open()); - fileName = file.fileName(); - file.close(); - } - QVERIFY(QFile::exists(fileName)); - QVERIFY(QFile::remove(fileName)); - - - // Do not explicitly call setAutoRemove (tests if it really is the default as documented) - { - QTemporaryFile file("tempXXXXXX"); - QVERIFY(file.open()); - fileName = file.fileName(); - file.close(); - } - QVERIFY(!QFile::exists(fileName)); + // Test auto remove + QString fileName; + { + QTemporaryFile file("tempXXXXXX"); + file.setAutoRemove(true); + QVERIFY(file.open()); + fileName = file.fileName(); + file.close(); + } + QVERIFY(!QFile::exists(fileName)); + // Test if disabling auto remove works. + { + QTemporaryFile file("tempXXXXXX"); + file.setAutoRemove(false); + QVERIFY(file.open()); + fileName = file.fileName(); + file.close(); + } + QVERIFY(QFile::exists(fileName)); + QVERIFY(QFile::remove(fileName)); + + // Do not explicitly call setAutoRemove (tests if it really is the default as documented) + { + QTemporaryFile file("tempXXXXXX"); + QVERIFY(file.open()); + fileName = file.fileName(); + file.close(); + } + QVERIFY(!QFile::exists(fileName)); } void tst_QTemporaryFile::nonWritableCurrentDir() diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index 8fcc076905..f51b4fcdd7 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -796,84 +796,83 @@ void tst_QUrl::resolving() QCOMPARE(url.resolved(relativeUrl).toString(), relsolvedUrl); } - void tst_QUrl::toString_data() { QTest::addColumn<QString>("urlString"); QTest::addColumn<uint>("options"); QTest::addColumn<QString>("string"); - QTest::newRow("data0") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") - << uint(QUrl::RemoveScheme) - << QString::fromLatin1("//ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top"); + QTest::newRow("data0") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") + << uint(QUrl::RemoveScheme) + << QString::fromLatin1("//ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top"); - QTest::newRow("data2") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") - << uint(QUrl::RemovePassword) - << QString::fromLatin1("http://ole@www.troll.no:9090/index.html?ole=semann&gud=hei#top"); + QTest::newRow("data2") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") + << uint(QUrl::RemovePassword) + << QString::fromLatin1("http://ole@www.troll.no:9090/index.html?ole=semann&gud=hei#top"); - QTest::newRow("data3") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") - << uint(QUrl::RemoveUserInfo) - << QString::fromLatin1("http://www.troll.no:9090/index.html?ole=semann&gud=hei#top"); + QTest::newRow("data3") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") + << uint(QUrl::RemoveUserInfo) + << QString::fromLatin1("http://www.troll.no:9090/index.html?ole=semann&gud=hei#top"); - QTest::newRow("data4") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") - << uint(QUrl::RemovePort) - << QString::fromLatin1("http://ole:password@www.troll.no/index.html?ole=semann&gud=hei#top"); + QTest::newRow("data4") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") + << uint(QUrl::RemovePort) + << QString::fromLatin1("http://ole:password@www.troll.no/index.html?ole=semann&gud=hei#top"); - QTest::newRow("data5") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") - << uint(QUrl::RemoveAuthority) - << QString::fromLatin1("http:/index.html?ole=semann&gud=hei#top"); + QTest::newRow("data5") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") + << uint(QUrl::RemoveAuthority) + << QString::fromLatin1("http:/index.html?ole=semann&gud=hei#top"); - QTest::newRow("data6") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") - << uint(QUrl::RemovePath) - << QString::fromLatin1("http://ole:password@www.troll.no:9090?ole=semann&gud=hei#top"); + QTest::newRow("data6") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") + << uint(QUrl::RemovePath) + << QString::fromLatin1("http://ole:password@www.troll.no:9090?ole=semann&gud=hei#top"); - QTest::newRow("data7") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") - << uint(QUrl::RemoveQuery) - << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html#top"); + QTest::newRow("data7") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") + << uint(QUrl::RemoveQuery) + << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html#top"); - QTest::newRow("data8") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") - << uint(QUrl::RemoveFragment) - << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei"); + QTest::newRow("data8") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") + << uint(QUrl::RemoveFragment) + << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei"); - QTest::newRow("data9") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") - << uint(QUrl::RemoveScheme | QUrl::RemovePassword) - << QString::fromLatin1("//ole@www.troll.no:9090/index.html?ole=semann&gud=hei#top"); + QTest::newRow("data9") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") + << uint(QUrl::RemoveScheme | QUrl::RemovePassword) + << QString::fromLatin1("//ole@www.troll.no:9090/index.html?ole=semann&gud=hei#top"); QTest::newRow("data10") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") - << uint(QUrl::RemoveScheme | QUrl::RemoveUserInfo) - << QString::fromLatin1("//www.troll.no:9090/index.html?ole=semann&gud=hei#top"); + << uint(QUrl::RemoveScheme | QUrl::RemoveUserInfo) + << QString::fromLatin1("//www.troll.no:9090/index.html?ole=semann&gud=hei#top"); QTest::newRow("data11") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") - << uint(QUrl::RemoveScheme | QUrl::RemovePort) - << QString::fromLatin1("//ole:password@www.troll.no/index.html?ole=semann&gud=hei#top"); + << uint(QUrl::RemoveScheme | QUrl::RemovePort) + << QString::fromLatin1("//ole:password@www.troll.no/index.html?ole=semann&gud=hei#top"); QTest::newRow("data12") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") - << uint(QUrl::RemoveScheme | QUrl::RemoveAuthority) - << QString::fromLatin1("/index.html?ole=semann&gud=hei#top"); + << uint(QUrl::RemoveScheme | QUrl::RemoveAuthority) + << QString::fromLatin1("/index.html?ole=semann&gud=hei#top"); QTest::newRow("data13") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") - << uint(QUrl::RemoveScheme | QUrl::RemovePath) - << QString::fromLatin1("//ole:password@www.troll.no:9090?ole=semann&gud=hei#top"); + << uint(QUrl::RemoveScheme | QUrl::RemovePath) + << QString::fromLatin1("//ole:password@www.troll.no:9090?ole=semann&gud=hei#top"); QTest::newRow("data14") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") - << uint(QUrl::RemoveScheme | QUrl::RemoveAuthority | QUrl::RemoveFragment) - << QString::fromLatin1("/index.html?ole=semann&gud=hei"); + << uint(QUrl::RemoveScheme | QUrl::RemoveAuthority | QUrl::RemoveFragment) + << QString::fromLatin1("/index.html?ole=semann&gud=hei"); QTest::newRow("data15") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") - << uint(QUrl::RemoveAuthority | QUrl::RemoveQuery) - << QString::fromLatin1("http:/index.html#top"); + << uint(QUrl::RemoveAuthority | QUrl::RemoveQuery) + << QString::fromLatin1("http:/index.html#top"); QTest::newRow("data16") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") - << uint(QUrl::RemovePassword | QUrl::RemovePort - | QUrl::RemovePath | QUrl::RemoveQuery - | QUrl::RemoveFragment) - << QString::fromLatin1("http://ole@www.troll.no"); + << uint(QUrl::RemovePassword | QUrl::RemovePort + | QUrl::RemovePath | QUrl::RemoveQuery + | QUrl::RemoveFragment) + << QString::fromLatin1("http://ole@www.troll.no"); QTest::newRow("data17") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") - << uint(QUrl::RemoveScheme | QUrl::RemovePassword - | QUrl::RemovePort | QUrl::RemovePath - | QUrl::RemoveQuery | QUrl::RemoveFragment) - << QString::fromLatin1("//ole@www.troll.no"); + << uint(QUrl::RemoveScheme | QUrl::RemovePassword + | QUrl::RemovePort | QUrl::RemovePath + | QUrl::RemoveQuery | QUrl::RemoveFragment) + << QString::fromLatin1("//ole@www.troll.no"); QTest::newRow("data18") << QString::fromLatin1("http://andreas:hemmelig@www.vg.no/?my=query&your=query#yougotfragged") << uint(QUrl::None) @@ -911,18 +910,16 @@ void tst_QUrl::isParentOf_data() QTest::addColumn<QString>("child"); QTest::addColumn<bool>("trueFalse"); - QTest::newRow("data0") << QString::fromLatin1("http://a.b.c/d") - << QString::fromLatin1("http://a.b.c/d/e?f") << true; - QTest::newRow("data1") << QString::fromLatin1("http://a.b.c/d") - << QString::fromLatin1("http://a.b.c/d") << false; - QTest::newRow("data2") << QString::fromLatin1("http://a.b.c/d") - << QString::fromLatin1("http://a.b.c/de") << false; - QTest::newRow("data3") << QString::fromLatin1("http://a.b.c/d/") - << QString::fromLatin1("http://a.b.c/de") << false; - QTest::newRow("data4") << QString::fromLatin1("http://a.b.c/d/") - << QString::fromLatin1("http://a.b.c/d/e") << true; - - + QTest::newRow("data0") << QString::fromLatin1("http://a.b.c/d") + << QString::fromLatin1("http://a.b.c/d/e?f") << true; + QTest::newRow("data1") << QString::fromLatin1("http://a.b.c/d") + << QString::fromLatin1("http://a.b.c/d") << false; + QTest::newRow("data2") << QString::fromLatin1("http://a.b.c/d") + << QString::fromLatin1("http://a.b.c/de") << false; + QTest::newRow("data3") << QString::fromLatin1("http://a.b.c/d/") + << QString::fromLatin1("http://a.b.c/de") << false; + QTest::newRow("data4") << QString::fromLatin1("http://a.b.c/d/") + << QString::fromLatin1("http://a.b.c/d/e") << true; } void tst_QUrl::toString_constructed_data() @@ -941,16 +938,16 @@ void tst_QUrl::toString_constructed_data() QString n(""); QTest::newRow("data1") << n << n << n << QString::fromLatin1("qt.nokia.com") << -1 << QString::fromLatin1("index.html") - << QByteArray() << n << QString::fromLatin1("//qt.nokia.com/index.html") - << QByteArray("//qt.nokia.com/index.html"); + << QByteArray() << n << QString::fromLatin1("//qt.nokia.com/index.html") + << 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/"); + << "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/"); + << "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() @@ -968,21 +965,21 @@ void tst_QUrl::toString_constructed() QUrl url; if (!scheme.isEmpty()) - url.setScheme(scheme); + url.setScheme(scheme); if (!userName.isEmpty()) - url.setUserName(userName); + url.setUserName(userName); if (!password.isEmpty()) - url.setPassword(password); + url.setPassword(password); if (!host.isEmpty()) - url.setHost(host); + url.setHost(host); if (port != -1) - url.setPort(port); + url.setPort(port); if (!path.isEmpty()) - url.setPath(path); + url.setPath(path); if (!query.isEmpty()) - url.setEncodedQuery(query); + url.setEncodedQuery(query); if (!fragment.isEmpty()) - url.setFragment(fragment); + url.setFragment(fragment); QVERIFY(url.isValid()); QCOMPARE(url.toString(), asString); @@ -1006,14 +1003,14 @@ void tst_QUrl::toLocalFile_data() QTest::addColumn<QString>("theUrl"); QTest::addColumn<QString>("theFile"); - QTest::newRow("data0") << QString::fromLatin1("file:/a.txt") << QString::fromLatin1("/a.txt"); - QTest::newRow("data4") << QString::fromLatin1("file:///a.txt") << QString::fromLatin1("/a.txt"); - QTest::newRow("data5") << QString::fromLatin1("file:///c:/a.txt") << QString::fromLatin1("c:/a.txt"); - QTest::newRow("data6") << QString::fromLatin1("file://somehost/somedir/somefile") << QString::fromLatin1("//somehost/somedir/somefile"); - QTest::newRow("data7") << QString::fromLatin1("file://somehost/") << QString::fromLatin1("//somehost/"); - QTest::newRow("data8") << QString::fromLatin1("file://somehost") << QString::fromLatin1("//somehost"); - QTest::newRow("data9") << QString::fromLatin1("file:////somehost/somedir/somefile") << QString::fromLatin1("//somehost/somedir/somefile"); - QTest::newRow("data10") << QString::fromLatin1("FILE:/a.txt") << QString::fromLatin1("/a.txt"); + QTest::newRow("data0") << QString::fromLatin1("file:/a.txt") << QString::fromLatin1("/a.txt"); + QTest::newRow("data4") << QString::fromLatin1("file:///a.txt") << QString::fromLatin1("/a.txt"); + QTest::newRow("data5") << QString::fromLatin1("file:///c:/a.txt") << QString::fromLatin1("c:/a.txt"); + QTest::newRow("data6") << QString::fromLatin1("file://somehost/somedir/somefile") << QString::fromLatin1("//somehost/somedir/somefile"); + QTest::newRow("data7") << QString::fromLatin1("file://somehost/") << QString::fromLatin1("//somehost/"); + QTest::newRow("data8") << QString::fromLatin1("file://somehost") << QString::fromLatin1("//somehost"); + QTest::newRow("data9") << QString::fromLatin1("file:////somehost/somedir/somefile") << QString::fromLatin1("//somehost/somedir/somefile"); + QTest::newRow("data10") << QString::fromLatin1("FILE:/a.txt") << QString::fromLatin1("/a.txt"); // and some that result in empty (i.e., not local) QTest::newRow("xdata0") << QString::fromLatin1("/a.txt") << QString(); @@ -1039,16 +1036,16 @@ void tst_QUrl::fromLocalFile_data() QTest::addColumn<QString>("theUrl"); QTest::addColumn<QString>("thePath"); - QTest::newRow("data0") << QString::fromLatin1("/a.txt") << QString::fromLatin1("file:///a.txt") << QString::fromLatin1("/a.txt"); - QTest::newRow("data1") << QString::fromLatin1("a.txt") << QString::fromLatin1("file:a.txt") << QString::fromLatin1("a.txt"); - QTest::newRow("data2") << QString::fromLatin1("/a/b.txt") << QString::fromLatin1("file:///a/b.txt") << QString::fromLatin1("/a/b.txt"); - QTest::newRow("data3") << QString::fromLatin1("c:/a.txt") << QString::fromLatin1("file:///c:/a.txt") << QString::fromLatin1("/c:/a.txt"); - QTest::newRow("data4") << QString::fromLatin1("//somehost/somedir/somefile") << QString::fromLatin1("file://somehost/somedir/somefile") - << QString::fromLatin1("/somedir/somefile"); - QTest::newRow("data5") << QString::fromLatin1("//somehost") << QString::fromLatin1("file://somehost") - << QString::fromLatin1(""); - QTest::newRow("data6") << QString::fromLatin1("//somehost/") << QString::fromLatin1("file://somehost/") - << QString::fromLatin1("/"); + QTest::newRow("data0") << QString::fromLatin1("/a.txt") << QString::fromLatin1("file:///a.txt") << QString::fromLatin1("/a.txt"); + QTest::newRow("data1") << QString::fromLatin1("a.txt") << QString::fromLatin1("file:a.txt") << QString::fromLatin1("a.txt"); + QTest::newRow("data2") << QString::fromLatin1("/a/b.txt") << QString::fromLatin1("file:///a/b.txt") << QString::fromLatin1("/a/b.txt"); + QTest::newRow("data3") << QString::fromLatin1("c:/a.txt") << QString::fromLatin1("file:///c:/a.txt") << QString::fromLatin1("/c:/a.txt"); + QTest::newRow("data4") << QString::fromLatin1("//somehost/somedir/somefile") << QString::fromLatin1("file://somehost/somedir/somefile") + << QString::fromLatin1("/somedir/somefile"); + QTest::newRow("data5") << QString::fromLatin1("//somehost") << QString::fromLatin1("file://somehost") + << QString::fromLatin1(""); + QTest::newRow("data6") << QString::fromLatin1("//somehost/") << QString::fromLatin1("file://somehost/") + << QString::fromLatin1("/"); } void tst_QUrl::fromLocalFile() @@ -1066,32 +1063,32 @@ void tst_QUrl::fromLocalFile() void tst_QUrl::compat_legacy() { { - QUrl u( "file:bar" ); - QCOMPARE( u.toString(QUrl::RemoveScheme), QString("bar") ); + QUrl u( "file:bar" ); + QCOMPARE( u.toString(QUrl::RemoveScheme), QString("bar") ); } /* others */ { - QUrl u( "http://qt.nokia.com/images/ban/pgs_front.jpg" ); - QCOMPARE( u.path(), QString("/images/ban/pgs_front.jpg") ); + QUrl u( "http://qt.nokia.com/images/ban/pgs_front.jpg" ); + QCOMPARE( u.path(), QString("/images/ban/pgs_front.jpg") ); } { - QUrl tmp( "http://qt.nokia.com/images/ban/" ); - QUrl u = tmp.resolved(QString("pgs_front.jpg")); - QCOMPARE( u.path(), QString("/images/ban/pgs_front.jpg") ); + QUrl tmp( "http://qt.nokia.com/images/ban/" ); + QUrl u = tmp.resolved(QString("pgs_front.jpg")); + QCOMPARE( u.path(), QString("/images/ban/pgs_front.jpg") ); } { - QUrl tmp; - QUrl u = tmp.resolved(QString("http://qt.nokia.com/images/ban/pgs_front.jpg")); - QCOMPARE( u.path(), QString("/images/ban/pgs_front.jpg") ); + QUrl tmp; + QUrl u = tmp.resolved(QString("http://qt.nokia.com/images/ban/pgs_front.jpg")); + QCOMPARE( u.path(), QString("/images/ban/pgs_front.jpg") ); } { - QUrl tmp; - QUrl u = tmp.resolved(QString("http://qt.nokia.com/images/ban/pgs_front.jpg")); - QFileInfo fi(u.path()); - u.setPath(fi.path()); - QCOMPARE( u.path(), QString("/images/ban") ); + QUrl tmp; + QUrl u = tmp.resolved(QString("http://qt.nokia.com/images/ban/pgs_front.jpg")); + QFileInfo fi(u.path()); + u.setPath(fi.path()); + QCOMPARE( u.path(), QString("/images/ban") ); } } @@ -1124,16 +1121,16 @@ void tst_QUrl::compat_constructor_01() QFETCH( QString, urlStr ); { - QUrl empty; - QUrl u = empty.resolved(urlStr); + QUrl empty; + QUrl u = empty.resolved(urlStr); - QTEST( u.toString(), "res" ); + QTEST( u.toString(), "res" ); } { - QUrl empty; - QUrl u = empty.resolved(urlStr); + QUrl empty; + QUrl u = empty.resolved(urlStr); - QTEST( u.toString(), "res" ); + QTEST( u.toString(), "res" ); } } @@ -1277,17 +1274,17 @@ void tst_QUrl::compat_isValid_02() QUrl url; if ( !protocol.isEmpty() ) - url.setScheme( protocol ); + url.setScheme( protocol ); if ( !user.isEmpty() ) - url.setUserName( user ); + url.setUserName( user ); if ( !password.isEmpty() ) - url.setPassword( password ); + url.setPassword( password ); if ( !host.isEmpty() ) - url.setHost( host ); + url.setHost( host ); if ( port != -1 ) - url.setPort( port ); + url.setPort( port ); if ( !path.isEmpty() ) - url.setPath( path ); + url.setPath( path ); QVERIFY( url.isValid() == res ); } |