implemented wxMemoryInputStream::CanRead() and added tests for CanRead() to all stream tests

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44872 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-03-17 15:38:09 +00:00
parent 764471557e
commit 2d76b6d8c3
9 changed files with 43 additions and 18 deletions

View File

@@ -71,6 +71,7 @@ All:
- Added wxGridUpdateLocker helper class (Evgeniy Tarassov) - Added wxGridUpdateLocker helper class (Evgeniy Tarassov)
- Support wxGRID_AUTOSIZE in wxGrid::SetRow/ColLabelSize() (Evgeniy Tarassov) - Support wxGRID_AUTOSIZE in wxGrid::SetRow/ColLabelSize() (Evgeniy Tarassov)
- Added wxMemoryInputStream(wxInputStream&) ctor (Stas Sergeev) - Added wxMemoryInputStream(wxInputStream&) ctor (Stas Sergeev)
- Implemented wxMemoryInputStream::CanRead()
wxGTK: wxGTK:

View File

@@ -39,7 +39,8 @@ public:
virtual wxFileOffset GetLength() const { return m_length; } virtual wxFileOffset GetLength() const { return m_length; }
virtual bool IsSeekable() const { return true; } virtual bool IsSeekable() const { return true; }
char Peek(); virtual char Peek();
virtual bool CanRead() const;
wxStreamBuffer *GetInputStreamBuffer() const { return m_i_streambuf; } wxStreamBuffer *GetInputStreamBuffer() const { return m_i_streambuf; }

View File

@@ -97,6 +97,11 @@ wxMemoryInputStream::InitFromStream(wxInputStream& stream, wxFileOffset lenFile)
m_length = stream.LastRead(); m_length = stream.LastRead();
} }
bool wxMemoryInputStream::CanRead() const
{
return m_i_streambuf->GetIntPosition() != m_length;
}
wxMemoryInputStream::~wxMemoryInputStream() wxMemoryInputStream::~wxMemoryInputStream()
{ {
delete m_i_streambuf; delete m_i_streambuf;

View File

@@ -175,6 +175,19 @@ protected:
CPPUNIT_ASSERT(stream_in.LastRead() == 1); CPPUNIT_ASSERT(stream_in.LastRead() == 1);
} }
void Input_CanRead()
{
CleanupHelper cleanup(this);
TStreamIn &stream_in = CreateInStream();
CPPUNIT_ASSERT( stream_in.CanRead() );
// read the entire contents
(void)stream_in.Read(CreateOutStream());
CPPUNIT_ASSERT( !stream_in.CanRead() );
}
// Just try to perform a SeekI() on the input stream. // Just try to perform a SeekI() on the input stream.
void Input_SeekI() void Input_SeekI()
{ {

View File

@@ -47,6 +47,7 @@ public:
CPPUNIT_TEST(Input_Read); CPPUNIT_TEST(Input_Read);
CPPUNIT_TEST(Input_Eof); CPPUNIT_TEST(Input_Eof);
CPPUNIT_TEST(Input_LastRead); CPPUNIT_TEST(Input_LastRead);
CPPUNIT_TEST(Input_CanRead);
CPPUNIT_TEST(Input_SeekI); CPPUNIT_TEST(Input_SeekI);
CPPUNIT_TEST(Input_TellI); CPPUNIT_TEST(Input_TellI);
CPPUNIT_TEST(Input_Peek); CPPUNIT_TEST(Input_Peek);

View File

@@ -47,6 +47,7 @@ public:
CPPUNIT_TEST(Input_Read); CPPUNIT_TEST(Input_Read);
CPPUNIT_TEST(Input_Eof); CPPUNIT_TEST(Input_Eof);
CPPUNIT_TEST(Input_LastRead); CPPUNIT_TEST(Input_LastRead);
CPPUNIT_TEST(Input_CanRead);
CPPUNIT_TEST(Input_SeekI); CPPUNIT_TEST(Input_SeekI);
CPPUNIT_TEST(Input_TellI); CPPUNIT_TEST(Input_TellI);
CPPUNIT_TEST(Input_Peek); CPPUNIT_TEST(Input_Peek);

View File

@@ -44,6 +44,7 @@ public:
CPPUNIT_TEST(Input_Read); CPPUNIT_TEST(Input_Read);
CPPUNIT_TEST(Input_Eof); CPPUNIT_TEST(Input_Eof);
CPPUNIT_TEST(Input_LastRead); CPPUNIT_TEST(Input_LastRead);
CPPUNIT_TEST(Input_CanRead);
CPPUNIT_TEST(Input_SeekI); CPPUNIT_TEST(Input_SeekI);
CPPUNIT_TEST(Input_TellI); CPPUNIT_TEST(Input_TellI);
CPPUNIT_TEST(Input_Peek); CPPUNIT_TEST(Input_Peek);

View File

@@ -42,6 +42,7 @@ public:
CPPUNIT_TEST(Input_Read); CPPUNIT_TEST(Input_Read);
CPPUNIT_TEST(Input_Eof); CPPUNIT_TEST(Input_Eof);
CPPUNIT_TEST(Input_LastRead); CPPUNIT_TEST(Input_LastRead);
CPPUNIT_TEST(Input_CanRead);
CPPUNIT_TEST(Input_SeekI); CPPUNIT_TEST(Input_SeekI);
CPPUNIT_TEST(Input_TellI); CPPUNIT_TEST(Input_TellI);
CPPUNIT_TEST(Input_Peek); CPPUNIT_TEST(Input_Peek);

View File

@@ -55,6 +55,7 @@ public:
CPPUNIT_TEST(Input_Read); CPPUNIT_TEST(Input_Read);
CPPUNIT_TEST(Input_Eof); CPPUNIT_TEST(Input_Eof);
CPPUNIT_TEST(Input_LastRead); CPPUNIT_TEST(Input_LastRead);
CPPUNIT_TEST(Input_CanRead);
CPPUNIT_TEST_FAIL(Input_SeekI); CPPUNIT_TEST_FAIL(Input_SeekI);
CPPUNIT_TEST(Input_TellI); CPPUNIT_TEST(Input_TellI);
CPPUNIT_TEST(Input_Peek); CPPUNIT_TEST(Input_Peek);