summaryrefslogtreecommitdiffstats
path: root/tests/auto/qiodevice
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@nokia.com>2010-07-20 06:54:36 (GMT)
committerAndy Shaw <andy.shaw@nokia.com>2010-07-20 06:54:36 (GMT)
commit39721ae5cce44c3ea77d96a47d60aff54a91ad5c (patch)
treee26bfdfd74a4c2711cb0802c64eb03e4c4bbcac0 /tests/auto/qiodevice
parent2c574ed1bf9943130fb9af5435b557a47e3c462b (diff)
downloadQt-39721ae5cce44c3ea77d96a47d60aff54a91ad5c.zip
Qt-39721ae5cce44c3ea77d96a47d60aff54a91ad5c.tar.gz
Qt-39721ae5cce44c3ea77d96a47d60aff54a91ad5c.tar.bz2
Add a testcase for when peeking and then reading from a QIODevice
This case was broken and then fixed again recently, this testcase should ensure that it does not break again in the future. Reviewed-by: Andreas Kling
Diffstat (limited to 'tests/auto/qiodevice')
-rw-r--r--tests/auto/qiodevice/tst_qiodevice.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/qiodevice/tst_qiodevice.cpp b/tests/auto/qiodevice/tst_qiodevice.cpp
index 356e2f8..7048754 100644
--- a/tests/auto/qiodevice/tst_qiodevice.cpp
+++ b/tests/auto/qiodevice/tst_qiodevice.cpp
@@ -72,6 +72,7 @@ private slots:
void read_QByteArray();
void unget();
void peek();
+ void peekAndRead();
void getch();
void putch();
@@ -354,6 +355,31 @@ void tst_QIODevice::peek()
QFile::remove("peektestfile");
}
+void tst_QIODevice::peekAndRead()
+{
+ QByteArray originalData;
+ for (int i=0;i<1000;i++)
+ originalData += "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ QBuffer buffer;
+ QFile::remove("peektestfile");
+ QFile file("peektestfile");
+
+ for (int i = 0; i < 2; ++i) {
+ QByteArray readData;
+ QIODevice *device = i ? (QIODevice *)&file : (QIODevice *)&buffer;
+ device->open(QBuffer::ReadWrite);
+ device->write(originalData);
+ device->seek(0);
+ while (!device->atEnd()) {
+ char peekIn[26];
+ device->peek(peekIn, 26);
+ readData += device->read(26);
+ }
+ QCOMPARE(readData, originalData);
+ }
+ QFile::remove("peektestfile");
+}
+
void tst_QIODevice::getch()
{
#ifdef QT3_SUPPORT