diff options
Diffstat (limited to 'tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp')
-rw-r--r-- | tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp index d7c0574..66896a8 100644 --- a/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp +++ b/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp @@ -88,6 +88,7 @@ private slots: void rename(); void renameFdLeak(); void reOpenThroughQFile(); + void keepOpenMode(); public: }; @@ -439,5 +440,37 @@ void tst_QTemporaryFile::reOpenThroughQFile() QCOMPARE(file.readAll(), data); } +void tst_QTemporaryFile::keepOpenMode() +{ + QByteArray data("abcdefghij"); + + { + QTemporaryFile file; + QVERIFY(((QFile &)file).open(QIODevice::WriteOnly)); + QVERIFY(QIODevice::WriteOnly == file.openMode()); + + QCOMPARE(file.write(data), (qint64)data.size()); + file.close(); + + QVERIFY(((QFile &)file).open(QIODevice::ReadOnly)); + QVERIFY(QIODevice::ReadOnly == file.openMode()); + QCOMPARE(file.readAll(), data); + } + + { + QTemporaryFile file; + QVERIFY(file.open()); + QCOMPARE(file.write(data), (qint64)data.size()); + QVERIFY(file.rename("temporary-file.txt")); + + QVERIFY(((QFile &)file).open(QIODevice::ReadOnly)); + QVERIFY(QIODevice::ReadOnly == file.openMode()); + QCOMPARE(file.readAll(), data); + + QVERIFY(((QFile &)file).open(QIODevice::WriteOnly)); + QVERIFY(QIODevice::WriteOnly == file.openMode()); + } +} + QTEST_MAIN(tst_QTemporaryFile) #include "tst_qtemporaryfile.moc" |