diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2017-06-29 14:53:05 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2017-08-04 17:30:03 +0000 |
commit | 3d6cbe3409d52e5ca63b8d04261b8fd531d89c98 (patch) | |
tree | d4747085290bb913448152b2b68fb96bf96ad3e0 /tests/auto/corelib | |
parent | 3981a1f440914e8108af3d854a1b01dd596a8a0e (diff) |
Long live QTemporaryFileName!
So we can use it in QTemporaryFile, QTemporaryDir and QFile::rename()
[ChangeLog][QtCore][QTemporaryDir] The class now supports the "XXXXXX"
replacement token anywhere in the template, not just at the end. This
behavior is similar to what QTemporaryFile supports.
Change-Id: I1eba2b016de74620bfc8fffd14ccb645729de170
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r-- | tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp index 4bed8d0fd6..fcd9133099 100644 --- a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp +++ b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp @@ -148,25 +148,24 @@ void tst_QTemporaryDir::fileTemplate_data() { QTest::addColumn<QString>("constructorTemplate"); QTest::addColumn<QString>("prefix"); + QTest::addColumn<QString>("suffix"); + + QTest::newRow("default") << "" << "tst_qtemporarydir-" << ""; - QTest::newRow("constructor default") << "" << "tst_qtemporarydir-"; - - QTest::newRow("constructor with xxx sufix") << "qt_XXXXXXxxx" << "qt_XXXXXXxxx"; - QTest::newRow("constructor with xXx sufix") << "qt_XXXXXXxXx" << "qt_XXXXXXxXx"; - QTest::newRow("constructor with no suffix") << "qt_XXXXXX" << "qt_"; - QTest::newRow("constructor with >6 X's, no suffix") << "qt_XXXXXXXXXX" << "qt_"; - // When more than 6 X are present at the end, linux and windows will only replace the last 6, - // while Mac OS will actually replace all of them so we can only expect "qt_" (and check isValid). - QTest::newRow("constructor with XXXX suffix") << "qt_XXXXXX_XXXX" << "qt_"; - QTest::newRow("constructor with XXXX prefix") << "qt_XXXX" << "qt_"; - QTest::newRow("constructor with XXXXX prefix") << "qt_XXXXX" << "qt_"; + QTest::newRow("xxx-suffix") << "qt_XXXXXXxxx" << "qt_" << "xxx"; + QTest::newRow("xXx-suffix") << "qt_XXXXXXxXx" << "qt_" << "xXx"; + QTest::newRow("no-suffix") << "qt_XXXXXX" << "qt_" << ""; + QTest::newRow("10X") << "qt_XXXXXXXXXX" << "qt_" << ""; + QTest::newRow("4Xsuffix") << "qt_XXXXXX_XXXX" << "qt_" << "_XXXX"; + QTest::newRow("4Xprefix") << "qt_XXXX" << "qt_XXXX" << ""; + QTest::newRow("5Xprefix") << "qt_XXXXX" << "qt_XXXXX" << ""; if (canHandleUnicodeFileNames()) { // Test Umlauts (contained in Latin1) QString prefix = "qt_" + umlautTestText(); - QTest::newRow("Umlauts") << (prefix + "XXXXXX") << prefix; - // Test Chinese + QTest::newRow("Umlauts") << (prefix + "XXXXXX") << prefix << ""; + // test non-Latin1 prefix = "qt_" + hanTestText(); - QTest::newRow("Chinese characters") << (prefix + "XXXXXX") << prefix; + QTest::newRow("Chinese") << (prefix + "XXXXXX" + umlautTestText()) << prefix << umlautTestText(); } } @@ -174,14 +173,17 @@ void tst_QTemporaryDir::fileTemplate() { QFETCH(QString, constructorTemplate); QFETCH(QString, prefix); + QFETCH(QString, suffix); QTemporaryDir tempDir(constructorTemplate); QVERIFY(tempDir.isValid()); QString dirName = QDir(tempDir.path()).dirName(); - if (prefix.length()) + if (prefix.length()) { QCOMPARE(dirName.left(prefix.length()), prefix); + QCOMPARE(dirName.right(suffix.length()), suffix); + } } |