diff --git a/oscar/rawdata.cpp b/oscar/rawdata.cpp index ffbf58d4..bdbf9f07 100644 --- a/oscar/rawdata.cpp +++ b/oscar/rawdata.cpp @@ -138,14 +138,9 @@ bool RawDataDevice::isSequential() const return is_sequential; } -qint64 RawDataDevice::bytesAvailable() const -{ - return m_device.bytesAvailable(); -} - bool RawDataDevice::canReadLine() const { - return m_device.canReadLine(); + return m_device.canReadLine() || QIODevice::canReadLine(); } qint64 RawDataDevice::size() const diff --git a/oscar/rawdata.h b/oscar/rawdata.h index 8b0b7fa2..42b0102d 100644 --- a/oscar/rawdata.h +++ b/oscar/rawdata.h @@ -30,8 +30,6 @@ class RawDataDevice : public QIODevice virtual qint64 size() const; virtual bool seek(qint64 pos); - virtual qint64 bytesAvailable() const; - virtual bool canReadLine() const; virtual bool waitForReadyRead(int msecs); diff --git a/oscar/tests/rawdatatests.cpp b/oscar/tests/rawdatatests.cpp index d9d60951..d6c17ce1 100644 --- a/oscar/tests/rawdatatests.cpp +++ b/oscar/tests/rawdatatests.cpp @@ -95,12 +95,24 @@ void RawDataTests::testQIODeviceInterface() Q_ASSERT(ch == data[0]); Q_ASSERT(raw.size() == qio.size()); - Q_ASSERT(raw.atEnd() == qio.atEnd()); - Q_ASSERT(raw.bytesAvailable() == qio.bytesAvailable()); Q_ASSERT(raw.seek(16) == true); Q_ASSERT(raw.pos() == 16); Q_ASSERT(raw.pos() == qio.pos()); + Q_ASSERT(raw.atEnd() == qio.atEnd()); + + + // Check boundary conditions at end of device. + Q_ASSERT(raw.seek(255) == true); + Q_ASSERT(raw.getChar(&ch) == true); + Q_ASSERT(raw.pos() == qio.pos()); + Q_ASSERT(raw.atEnd() == true); + Q_ASSERT(raw.atEnd() == qio.atEnd()); + Q_ASSERT(raw.bytesAvailable() == qio.bytesAvailable()); + raw.ungetChar(ch); + Q_ASSERT(raw.atEnd() == false); + Q_ASSERT(raw.atEnd() != qio.atEnd()); + Q_ASSERT(raw.bytesAvailable() == qio.bytesAvailable() + 1); Q_ASSERT(raw.reset() == true); Q_ASSERT(raw.pos() == 0); @@ -111,6 +123,20 @@ void RawDataTests::testQIODeviceInterface() Q_ASSERT(raw.bytesAvailable() == qio.bytesAvailable()); + // canReadLine + Q_ASSERT(raw.canReadLine() == qio.canReadLine()); + raw.seek(255 - 0x0A); + Q_ASSERT(raw.canReadLine() == true); + Q_ASSERT(raw.canReadLine() == qio.canReadLine()); + Q_ASSERT(raw.getChar(&ch) == true); + Q_ASSERT(ch == 0x0A); + Q_ASSERT(raw.canReadLine() == false); + Q_ASSERT(raw.canReadLine() == qio.canReadLine()); + raw.ungetChar(ch); + Q_ASSERT(raw.canReadLine() == true); + Q_ASSERT(raw.canReadLine() != qio.canReadLine()); + + // readLine x2 Q_ASSERT(raw.reset() == true); Q_ASSERT(raw.canReadLine() == qio.canReadLine());