summaryrefslogtreecommitdiffstats
path: root/tests/auto/qtemporaryfile
diff options
context:
space:
mode:
authorJoão Abecasis <joao.abecasis@nokia.com>2011-03-30 12:11:33 (GMT)
committerJoão Abecasis <joao.abecasis@nokia.com>2011-04-04 11:22:43 (GMT)
commit892f78d6531ddfd698932e886ead4e66dbd4f0a9 (patch)
tree422f86a40b3d18767a4787b2fcfba79b1199999e /tests/auto/qtemporaryfile
parenta029db3e1c8de5ff20395904b9e37a009a2924c0 (diff)
downloadQt-892f78d6531ddfd698932e886ead4e66dbd4f0a9.zip
Qt-892f78d6531ddfd698932e886ead4e66dbd4f0a9.tar.gz
Qt-892f78d6531ddfd698932e886ead4e66dbd4f0a9.tar.bz2
Extending fileTemplate autotest
... to also verify template prefix and corner cases with runs of less than 6 Xs. Reviewed-by: Olivier Goffart Reviewed-by: Robin Burchell
Diffstat (limited to 'tests/auto/qtemporaryfile')
-rw-r--r--tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp40
1 files changed, 26 insertions, 14 deletions
diff --git a/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp
index e44aa1c..b6b0d3c 100644
--- a/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp
+++ b/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp
@@ -163,26 +163,35 @@ void tst_QTemporaryFile::cleanup()
void tst_QTemporaryFile::fileTemplate_data()
{
QTest::addColumn<QString>("constructorTemplate");
+ QTest::addColumn<QString>("prefix");
QTest::addColumn<QString>("suffix");
QTest::addColumn<QString>("fileTemplate");
- QTest::newRow("constructor default") << "" << "" << "";
- QTest::newRow("constructor with xxx sufix") << "qt_XXXXXXxxx" << "xxx" << "";
- QTest::newRow("constructor with xXx sufix") << "qt_XXXXXXxXx" << "xXx" << "";
- QTest::newRow("constructor with no sufix") << "qt_XXXXXX" << "" << "";
- QTest::newRow("constructor with >6 X's and xxx suffix") << "qt_XXXXXXXXXXxxx" << "xxx" << "";
- QTest::newRow("constructor with >6 X's, no suffix") << "qt_XXXXXXXXXX" << "" << "";
-
- QTest::newRow("set template, no suffix") << "" << "" << "foo";
- QTest::newRow("set template, with lowercase XXXXXX") << "" << "xxxxxx" << "qt_XXXXXXxxxxxx";
- QTest::newRow("set template, with xxx") << "" << ".xxx" << "qt_XXXXXX.xxx";
- QTest::newRow("set template, with >6 X's") << "" << ".xxx" << "qt_XXXXXXXXXXXXXX.xxx";
- QTest::newRow("set template, with >6 X's, no suffix") << "" << "" << "qt_XXXXXXXXXXXXXX";
+ QTest::newRow("constructor default") << "" << "." << "" << "";
+ QTest::newRow("constructor with xxx sufix") << "qt_XXXXXXxxx" << "qt_" << "xxx" << "";
+ QTest::newRow("constructor with xXx sufix") << "qt_XXXXXXxXx" << "qt_" << "xXx" << "";
+ QTest::newRow("constructor with no sufix") << "qt_XXXXXX" << "qt_" << "" << "";
+ QTest::newRow("constructor with >6 X's and xxx suffix") << "qt_XXXXXXXXXXxxx" << "qt_" << "xxx" << "";
+ QTest::newRow("constructor with >6 X's, no suffix") << "qt_XXXXXXXXXX" << "qt_" << "" << "";
+
+ QTest::newRow("constructor with XXXX suffix") << "qt_XXXXXX_XXXX" << "qt_" << "_XXXX" << "";
+ QTest::newRow("constructor with XXXXX suffix") << "qt_XXXXXX_XXXXX" << "qt_" << "_XXXXX" << "";
+ QTest::newRow("constructor with XXXX prefix") << "qt_XXXX" << "qt_XXXX." << "" << "";
+ QTest::newRow("constructor with XXXXX prefix") << "qt_XXXXX" << "qt_XXXXX." << "" << "";
+ QTest::newRow("constructor with XXXX prefix and suffix") << "qt_XXXX_XXXXXX_XXXX" << "qt_XXXX_" << "_XXXX" << "";
+ QTest::newRow("constructor with XXXXX prefix and suffix") << "qt_XXXXX_XXXXXX_XXXXX" << "qt_XXXXX_" << "_XXXXX" << "";
+
+ QTest::newRow("set template, no suffix") << "" << "foo" << "" << "foo";
+ QTest::newRow("set template, with lowercase XXXXXX") << "" << "qt_" << "xxxxxx" << "qt_XXXXXXxxxxxx";
+ QTest::newRow("set template, with xxx") << "" << "qt_" << ".xxx" << "qt_XXXXXX.xxx";
+ QTest::newRow("set template, with >6 X's") << "" << "qt_" << ".xxx" << "qt_XXXXXXXXXXXXXX.xxx";
+ QTest::newRow("set template, with >6 X's, no suffix") << "" << "qt_" << "" << "qt_XXXXXXXXXXXXXX";
}
void tst_QTemporaryFile::fileTemplate()
{
QFETCH(QString, constructorTemplate);
+ QFETCH(QString, prefix);
QFETCH(QString, suffix);
QFETCH(QString, fileTemplate);
@@ -192,8 +201,11 @@ void tst_QTemporaryFile::fileTemplate()
QCOMPARE(file.open(), true);
- QCOMPARE(file.fileName().right(suffix.length()), suffix);
- file.close();
+ if (prefix.length())
+ QCOMPARE(file.fileName().left(prefix.length()), prefix);
+
+ if (suffix.length())
+ QCOMPARE(file.fileName().right(suffix.length()), suffix);
}