diff options
author | João Abecasis <joao@abecasis.name> | 2009-06-29 11:42:43 (GMT) |
---|---|---|
committer | João Abecasis <joao@abecasis.name> | 2009-06-29 16:14:03 (GMT) |
commit | ccd06993cbb00058c937f28e8aa17dab87b448de (patch) | |
tree | e5db7d230c8c2df57c89a19e5c4cdd06fa9d13a6 /tests | |
parent | 02ed2cd9ddf57ee9daadbfc76e6b73dbd4165583 (diff) | |
download | Qt-ccd06993cbb00058c937f28e8aa17dab87b448de.zip Qt-ccd06993cbb00058c937f28e8aa17dab87b448de.tar.gz Qt-ccd06993cbb00058c937f28e8aa17dab87b448de.tar.bz2 |
QTemporaryFile: Report the user-provided openMode
Reviewed-by: Thiago
Diffstat (limited to 'tests')
-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" |