diff options
-rw-r--r-- | src/corelib/io/qdir.cpp | 2 | ||||
-rw-r--r-- | tests/auto/corelib/io/qdir/tst_qdir.cpp | 11 | ||||
-rw-r--r-- | tests/auto/tools/qmakelib/evaltest.cpp | 4 |
3 files changed, 11 insertions, 6 deletions
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 9b1ec3917a..6687ff846c 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -777,6 +777,8 @@ QString QDir::relativeFilePath(const QString &fileName) const result += QLatin1Char('/'); } + if (result.isEmpty()) + return QLatin1String("."); return result; } diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index e8a7105f6e..45289df398 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -1366,6 +1366,9 @@ void tst_QDir::relativeFilePath_data() QTest::newRow("11") << "" << "" << ""; + QTest::newRow("same path 1") << "/tmp" << "/tmp" << "."; + QTest::newRow("same path 2") << "//tmp" << "/tmp/" << "."; + #if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) QTest::newRow("12") << "C:/foo/bar" << "ding" << "ding"; QTest::newRow("13") << "C:/foo/bar" << "C:/ding/dong" << "../../ding/dong"; @@ -1373,10 +1376,10 @@ void tst_QDir::relativeFilePath_data() QTest::newRow("15") << "C:/foo/bar" << "D:/ding/dong" << "D:/ding/dong"; QTest::newRow("16") << "C:" << "C:/ding/dong" << "ding/dong"; QTest::newRow("17") << "C:/" << "C:/ding/dong" << "ding/dong"; - QTest::newRow("18") << "C:" << "C:" << ""; - QTest::newRow("19") << "C:/" << "C:" << ""; - QTest::newRow("20") << "C:" << "C:/" << ""; - QTest::newRow("21") << "C:/" << "C:/" << ""; + QTest::newRow("18") << "C:" << "C:" << "."; + QTest::newRow("19") << "C:/" << "C:" << "."; + QTest::newRow("20") << "C:" << "C:/" << "."; + QTest::newRow("21") << "C:/" << "C:/" << "."; QTest::newRow("22") << "C:" << "C:file.txt" << "file.txt"; QTest::newRow("23") << "C:/" << "C:file.txt" << "file.txt"; QTest::newRow("24") << "C:" << "C:/file.txt" << "file.txt"; diff --git a/tests/auto/tools/qmakelib/evaltest.cpp b/tests/auto/tools/qmakelib/evaltest.cpp index fab2cdce17..bed4c792a1 100644 --- a/tests/auto/tools/qmakelib/evaltest.cpp +++ b/tests/auto/tools/qmakelib/evaltest.cpp @@ -1356,7 +1356,7 @@ void tst_qmakelib::addReplaceFunctions(const QString &qindir) QTest::newRow("$$relative_path(): relative file to empty") << "VAR = $$relative_path(dir/..)" - << "VAR =" + << "VAR = ." << "" << true; @@ -1368,7 +1368,7 @@ void tst_qmakelib::addReplaceFunctions(const QString &qindir) QTest::newRow("$$relative_path(): empty file & path") << "VAR = $$relative_path('', /root/sub)" - << "VAR =" + << "VAR = ." << "" << true; |