diff options
-rw-r--r-- | tests/auto/qiodevice/tst_qiodevice.cpp | 26 |
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 |