summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoão Abecasis <joao@abecasis.name>2009-06-29 11:42:43 (GMT)
committerJoão Abecasis <joao@abecasis.name>2009-06-29 16:14:03 (GMT)
commitccd06993cbb00058c937f28e8aa17dab87b448de (patch)
treee5db7d230c8c2df57c89a19e5c4cdd06fa9d13a6 /tests
parent02ed2cd9ddf57ee9daadbfc76e6b73dbd4165583 (diff)
downloadQt-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.cpp33
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"