diff --git a/src/common/mstream.cpp b/src/common/mstream.cpp index 9df71df414..b8aaa4765b 100644 --- a/src/common/mstream.cpp +++ b/src/common/mstream.cpp @@ -112,10 +112,12 @@ char wxMemoryInputStream::Peek() if ( pos == m_length ) { m_lasterror = wxSTREAM_READ_ERROR; + m_lastcount = 0; return 0; } + m_lastcount = 1; return buf[pos]; } diff --git a/tests/streams/bstream.h b/tests/streams/bstream.h index c7381844e9..e01c054d56 100644 --- a/tests/streams/bstream.h +++ b/tests/streams/bstream.h @@ -253,9 +253,17 @@ protected: while (stream_in.IsOk()) { char peekChar = stream_in.Peek(); + size_t peekLastRead = stream_in.LastRead(); + char getChar = stream_in.GetC(); + + // Peek and GetC should retrieve the same 0 or 1 characters. + CPPUNIT_ASSERT_EQUAL(peekLastRead, stream_in.LastRead()); + if (stream_in.LastRead() == 1) + { CPPUNIT_ASSERT_EQUAL(getChar, peekChar); + } } }