summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qdir/tst_qdir.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/io/qdir/tst_qdir.cpp')
-rw-r--r--tests/auto/corelib/io/qdir/tst_qdir.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp
index 294a53645e..b86c6e4dfa 100644
--- a/tests/auto/corelib/io/qdir/tst_qdir.cpp
+++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp
@@ -58,7 +58,8 @@
#ifdef QT_BUILD_INTERNAL
QT_BEGIN_NAMESPACE
-extern Q_AUTOTEST_EXPORT QString qt_normalizePathSegments(const QString &, bool);
+extern Q_AUTOTEST_EXPORT QString
+ qt_normalizePathSegments(const QString &path, bool allowUncPaths, bool *ok = nullptr);
QT_END_NAMESPACE
#endif
@@ -1149,6 +1150,8 @@ tst_QDir::cleanPath_data()
QTest::newRow("data0") << "/Users/sam/troll/qt4.0//.." << "/Users/sam/troll";
QTest::newRow("data1") << "/Users/sam////troll/qt4.0//.." << "/Users/sam/troll";
QTest::newRow("data2") << "/" << "/";
+ QTest::newRow("data2-up") << "/path/.." << "/";
+ QTest::newRow("data2-above-root") << "/.." << "/..";
QTest::newRow("data3") << QDir::cleanPath("../.") << "..";
QTest::newRow("data4") << QDir::cleanPath("../..") << "../..";
#if defined(Q_OS_WIN)
@@ -1178,13 +1181,19 @@ tst_QDir::cleanPath_data()
QTest::newRow("data14") << "c://foo" << "c:/foo";
// Drive letters and unc path in one string
-#ifndef Q_OS_WINRT
-#ifdef Q_OS_WIN
+#if defined(Q_OS_WINRT)
+ const QString root = QDir::rootPath(); // has trailing slash
+ QTest::newRow("root-up") << (root + "path/..") << root;
+ QTest::newRow("above-root") << (root + "..") << (root + "..");
+#elif defined(Q_OS_WIN)
QTest::newRow("data15") << "//c:/foo" << "//c:/foo";
+ QTest::newRow("drive-up") << "A:/path/.." << "A:/";
+ QTest::newRow("drive-above-root") << "A:/.." << "A:/..";
+ QTest::newRow("unc-server-up") << "//server/path/.." << "//server";
+ QTest::newRow("unc-server-above-root") << "//server/.." << "//server/..";
#else
QTest::newRow("data15") << "//c:/foo" << "/c:/foo";
-#endif
-#endif // !Q_OS_WINRT
+#endif // non-windows
QTest::newRow("QTBUG-23892_0") << "foo/.." << ".";
QTest::newRow("QTBUG-23892_1") << "foo/../" << ".";
@@ -2238,6 +2247,10 @@ void tst_QDir::cdBelowRoot_data()
const QString systemRoot = QString::fromLocal8Bit(qgetenv("SystemRoot"));
QTest::newRow("windows-drive")
<< systemDrive << systemRoot.mid(3) << QDir::cleanPath(systemRoot);
+ const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName();
+ const QString testDirectory = QStringLiteral("testshare");
+ QTest::newRow("windows-share")
+ << uncRoot << testDirectory << QDir::cleanPath(uncRoot + QLatin1Char('/') + testDirectory);
#endif // Windows
}