diff options
author | João Abecasis <joao.abecasis@nokia.com> | 2012-08-20 13:09:55 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-09-25 00:08:16 +0200 |
commit | 0c2b7b1020384c095500599a687a88306f98c0f6 (patch) | |
tree | 873360826de12a7d559e8eeb4f4fd28f269ace3c /tests/auto/corelib/io | |
parent | ba2c485c55eb2d0bf4c2478f604f51840908d30a (diff) |
Fix default-constructed QFileSystemEntry
Member variables for lastSeparator, first and lastDotInFileName are now
initialized to -1 (non-existing), where the previous value of zero would
mean a separator/dot at that position and resulted in path() returning
'/', instead of '.'.
Tests were expanded for better coverage of empty state and
default-constructed instances.
Change-Id: Ie27547886b52224d38b5be0b4f920c9927fd440f
Reviewed-by: Andy Shaw <andy.shaw@digia.com>
Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
Diffstat (limited to 'tests/auto/corelib/io')
-rw-r--r-- | tests/auto/corelib/io/qfilesystementry/tst_qfilesystementry.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/corelib/io/qfilesystementry/tst_qfilesystementry.cpp b/tests/auto/corelib/io/qfilesystementry/tst_qfilesystementry.cpp index 1ea5c93fe7..0ecadd17c4 100644 --- a/tests/auto/corelib/io/qfilesystementry/tst_qfilesystementry.cpp +++ b/tests/auto/corelib/io/qfilesystementry/tst_qfilesystementry.cpp @@ -64,6 +64,7 @@ private slots: #endif void isClean_data(); void isClean(); + void defaultCtor(); }; #if defined(Q_OS_WIN) @@ -169,10 +170,16 @@ void tst_QFileSystemEntry::getSetCheck_data() QTest::addColumn<QString>("completeSuffix"); QTest::addColumn<bool>("absolute"); + QTest::newRow("empty") + << QByteArray() + << QString() + << QString() << QString() << QString() << QString() << QString() << false; + QTest::newRow("simple") << QByteArray("/home/qt/in/a/dir.tar.gz") << "/home/qt/in/a/dir.tar.gz" << "dir.tar.gz" << "dir" << "dir.tar" << "gz" << "tar.gz" << true; + QTest::newRow("relative") << QByteArray("in/a/dir.tar.gz") << "in/a/dir.tar.gz" @@ -235,6 +242,7 @@ void tst_QFileSystemEntry::suffix_data() QTest::addColumn<QString>("file"); QTest::addColumn<QString>("expected"); + QTest::newRow("empty") << QString() << QString(); QTest::newRow("noextension0") << "file" << ""; QTest::newRow("noextension1") << "/path/to/file" << ""; QTest::newRow("data0") << "file.tar" << "tar"; @@ -273,6 +281,7 @@ void tst_QFileSystemEntry::completeSuffix_data() QTest::addColumn<QString>("file"); QTest::addColumn<QString>("expected"); + QTest::newRow("empty") << QString() << QString(); QTest::newRow("noextension0") << "file" << ""; QTest::newRow("noextension1") << "/path/to/file" << ""; QTest::newRow("data0") << "file.tar" << "tar"; @@ -302,6 +311,7 @@ void tst_QFileSystemEntry::baseName_data() QTest::addColumn<QString>("file"); QTest::addColumn<QString>("expected"); + QTest::newRow("empty") << QString() << QString(); QTest::newRow("data0") << "file.tar" << "file"; QTest::newRow("data1") << "file.tar.gz" << "file"; QTest::newRow("data2") << "/path/file/file.tar.gz" << "file"; @@ -330,6 +340,7 @@ void tst_QFileSystemEntry::completeBaseName_data() QTest::addColumn<QString>("file"); QTest::addColumn<QString>("expected"); + QTest::newRow("empty") << QString() << QString(); QTest::newRow("data0") << "file.tar" << "file"; QTest::newRow("data1") << "file.tar.gz" << "file.tar"; QTest::newRow("data2") << "/path/file/file.tar.gz" << "file.tar"; @@ -360,6 +371,7 @@ void tst_QFileSystemEntry::absoluteOrRelative_data() QTest::addColumn<bool>("isAbsolute"); QTest::addColumn<bool>("isRelative"); + QTest::newRow("empty") << QString() << false << true; QTest::newRow("data0") << "file.tar" << false << true; QTest::newRow("data1") << "/path/file/file.tar.gz" << false << false; QTest::newRow("data1") << "C:path/file/file.tar.gz" << false << false; @@ -384,6 +396,7 @@ void tst_QFileSystemEntry::isClean_data() QTest::addColumn<QString>("path"); QTest::addColumn<bool>("isClean"); + QTest::newRow("empty") << QString() << true; QTest::newRow("simple") << "foo" << true; QTest::newRow("complex") << "/foo/bar/bz" << true; QTest::newRow(".file") << "/foo/.file" << true; @@ -409,5 +422,33 @@ void tst_QFileSystemEntry::isClean() QCOMPARE(fi.isClean(), isClean); } +void tst_QFileSystemEntry::defaultCtor() +{ + QFileSystemEntry entry; + + QVERIFY(entry.filePath().isNull()); + QVERIFY(entry.nativeFilePath().isNull()); + + QVERIFY(entry.fileName().isNull()); + QCOMPARE(entry.path(), QString(".")); + + QVERIFY(entry.baseName().isNull()); + QVERIFY(entry.completeBaseName().isNull()); + QVERIFY(entry.suffix().isNull()); + QVERIFY(entry.completeSuffix().isNull()); + + QVERIFY(!entry.isAbsolute()); + QVERIFY(entry.isRelative()); + + QVERIFY(entry.isClean()); + +#if defined(Q_OS_WIN) + QVERIFY(!entry.isDriveRoot()); +#endif + QVERIFY(!entry.isRoot()); + + QVERIFY(entry.isEmpty()); +} + QTEST_MAIN(tst_QFileSystemEntry) #include <tst_qfilesystementry.moc> |