From ec8c1dcf147ac71ea3c0105d67c2575ab733d348 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Thu, 4 Jun 2015 16:02:06 +0200 Subject: Make QDir::relativeFilePath() return "." for a path to itself. The rationale being that the empty string is not a valid path component. [ChangeLog][QtCore][QDir] QDir::relativeFilePath() now returns "." instead of an empty string if the given path is the same as the directory. Change-Id: Ibcf31904b2ae5edf5639d4c2e5ba234365d347fd Reviewed-by: Oswald Buddenhagen --- tests/auto/corelib/io/qdir/tst_qdir.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'tests/auto/corelib/io/qdir/tst_qdir.cpp') 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"; -- cgit v1.2.3