diff options
Diffstat (limited to 'tests/auto/corelib/io/qdir/tst_qdir.cpp')
-rw-r--r-- | tests/auto/corelib/io/qdir/tst_qdir.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index 1162fb31e4..5462a63fab 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -216,6 +216,8 @@ private slots: void emptyDir(); void nonEmptyDir(); + void stdfilesystem(); + private: #ifdef BUILTIN_TESTDATA QString m_dataPath; @@ -2403,6 +2405,45 @@ void tst_QDir::nonEmptyDir() QVERIFY(!dir.isEmpty()); } +void tst_QDir::stdfilesystem() +{ +#if QT_CONFIG(cxx17_filesystem) + namespace fs = std::filesystem; + fs::path path("."); + QDir dir(path); + QCOMPARE(dir, QDir(QStringLiteral("."))); + + path = path / "testdir" / "dir"; + dir.setPath(path); + + QCOMPARE(dir, QDir(QStringLiteral("./testdir/dir"))); + + auto fsPath = dir.filesystemPath(); + QCOMPARE(QString::fromStdU16String(fsPath.u16string()), dir.path()); + fsPath = dir.filesystemAbsolutePath(); + QCOMPARE(QString::fromStdU16String(fsPath.u16string()), dir.absolutePath()); + fsPath = dir.filesystemCanonicalPath(); + QCOMPARE(QString::fromStdU16String(fsPath.u16string()), dir.canonicalPath()); + + QDir emptyPath(fs::path{}); + QCOMPARE(emptyPath, QDir(QStringLiteral("."))); + + { + // Test QDir ctor with filter and sorting reversed + QDir filteredDir(fs::path{"."} / "searchdir", "subdir*", + QDir::SortFlag::Reversed, QDir::Filter::Dirs); + QStringList entries = filteredDir.entryList(); + QCOMPARE(entries, QStringList() << "subdir2" << "subdir1"); + QCOMPARE(filteredDir.sorting(), QDir::SortFlag::Reversed); + QCOMPARE(filteredDir.filter(), QDir::Filter::Dirs); + QCOMPARE(filteredDir.nameFilters().length(), 1); + QCOMPARE(filteredDir.nameFilters().first(), "subdir*"); + } +#else + QSKIP("Not supported"); +#endif +} + QTEST_MAIN(tst_QDir) #include "tst_qdir.moc" |