Merge branch 'memstream-peek'
Return 1 from LastRead() after successful wxMemoryInputStream::Peek() call. See #23758.
This commit is contained in:
commit
b284ede300
3 changed files with 17 additions and 1 deletions
|
|
@ -610,12 +610,18 @@ public:
|
|||
int GetC();
|
||||
|
||||
/**
|
||||
Returns the last number of bytes read.
|
||||
Returns the last number of bytes read by the last input operation.
|
||||
|
||||
Such operations include Read(), GetC() and Peek().
|
||||
*/
|
||||
virtual size_t LastRead() const;
|
||||
|
||||
/**
|
||||
Returns the first character in the input queue without removing it.
|
||||
|
||||
If Peek() failed, e.g. because there is nothing more to read in the
|
||||
stream, LastRead() will return 0 after calling it, otherwise it will
|
||||
return 1.
|
||||
*/
|
||||
virtual char Peek();
|
||||
|
||||
|
|
|
|||
|
|
@ -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,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue