Update wxMemoryInputStream::Peek to set last read count.
This aligns the memory stream's Peek with other streams' Peek impls by making it set the last read count to 1 when it successfully peeks a character, or 0 when it does not. While the formal docs do not link Peek to LastCount directly, the in-source comments on the declaration of both wxInputStream::Peek and wxInputStream::LastRead both indicate that Peek will set the last read count.
This commit is contained in:
parent
d847f3b039
commit
ffe520cb6d
2 changed files with 10 additions and 0 deletions
|
|
@ -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];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -253,11 +253,19 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Just try to perform a Ungetch() on the input stream.
|
||||
void Input_Ungetch()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue