stream tests improvements (patch 924438)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26716 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -37,7 +37,7 @@ class StreamCase : public TestSuite
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
StreamCase()
|
StreamCase()
|
||||||
:TestSuite("Streams")
|
:TestSuite(STREAM_TEST_NAME)
|
||||||
{ /* Nothing extra */ }
|
{ /* Nothing extra */ }
|
||||||
static Test *suite();
|
static Test *suite();
|
||||||
};
|
};
|
||||||
|
@@ -14,17 +14,19 @@
|
|||||||
using namespace CppUnit;
|
using namespace CppUnit;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Some macros preventing use from typing too much ;-)
|
// Some macros preventing us from typing too much ;-)
|
||||||
//
|
//
|
||||||
|
|
||||||
#define STREAM_TEST_NAME "Streams"
|
#define STREAM_TEST_NAME "Streams"
|
||||||
|
#define COMPOSE_TEST_NAME(Name) \
|
||||||
|
STREAM_TEST_NAME "." #Name
|
||||||
#define STREAM_REGISTER_SUB_SUITE(Name) \
|
#define STREAM_REGISTER_SUB_SUITE(Name) \
|
||||||
extern Test* Get##Name##Suite(); \
|
extern Test* Get##Name##Suite(); \
|
||||||
suite->addTest(Get##Name##Suite())
|
suite->addTest(Get##Name##Suite())
|
||||||
#define STREAM_IMPLEMENT_SUB_REGISTRATION_ROUTINE(Name) \
|
#define STREAM_IMPLEMENT_SUB_REGISTRATION_ROUTINE(Name) \
|
||||||
Test* Get##Name##Suite() { return Name::suite(); }
|
Test* Get##Name##Suite() { return Name::suite(); }
|
||||||
#define STREAM_TEST_SUBSUITE_NAMED_REGISTRATION(Name) \
|
#define STREAM_TEST_SUBSUITE_NAMED_REGISTRATION(Name) \
|
||||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( Name, STREAM_TEST_NAME "." #Name ); \
|
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( Name, COMPOSE_TEST_NAME(Name) ); \
|
||||||
STREAM_IMPLEMENT_SUB_REGISTRATION_ROUTINE( Name )
|
STREAM_IMPLEMENT_SUB_REGISTRATION_ROUTINE( Name )
|
||||||
|
|
||||||
|
|
||||||
@@ -57,6 +59,7 @@ public:
|
|||||||
BaseStreamTestCase()
|
BaseStreamTestCase()
|
||||||
:m_bSimpleTellITest(false),
|
:m_bSimpleTellITest(false),
|
||||||
m_bSimpleTellOTest(false),
|
m_bSimpleTellOTest(false),
|
||||||
|
m_bSeekInvalidBeyondEnd(true),
|
||||||
m_pCurrentIn(NULL),
|
m_pCurrentIn(NULL),
|
||||||
m_pCurrentOut(NULL)
|
m_pCurrentOut(NULL)
|
||||||
{ /* Nothing extra */ }
|
{ /* Nothing extra */ }
|
||||||
@@ -176,7 +179,7 @@ protected:
|
|||||||
//CPPUNIT_ASSERT(stream_in.SeekI(-2, wxFromEnd) == (off_t)stream_in.GetSize()-2);
|
//CPPUNIT_ASSERT(stream_in.SeekI(-2, wxFromEnd) == (off_t)stream_in.GetSize()-2);
|
||||||
CPPUNIT_ASSERT(stream_in.SeekI(-2, wxFromEnd) != wxInvalidOffset);
|
CPPUNIT_ASSERT(stream_in.SeekI(-2, wxFromEnd) != wxInvalidOffset);
|
||||||
// Go beyond the stream size.
|
// Go beyond the stream size.
|
||||||
CPPUNIT_ASSERT(stream_in.SeekI(10, wxFromCurrent) == wxInvalidOffset);
|
CPPUNIT_ASSERT((stream_in.SeekI(10, wxFromCurrent) == wxInvalidOffset) == m_bSeekInvalidBeyondEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Just try to perform a TellI() on the input stream.
|
// Just try to perform a TellI() on the input stream.
|
||||||
@@ -210,13 +213,11 @@ protected:
|
|||||||
TStreamIn &stream_in = CreateInStream();
|
TStreamIn &stream_in = CreateInStream();
|
||||||
|
|
||||||
// Test the full stream
|
// Test the full stream
|
||||||
while(!stream_in.Eof())
|
while (stream_in.IsOk())
|
||||||
{
|
{
|
||||||
if (!stream_in.IsOk())
|
|
||||||
break;
|
|
||||||
|
|
||||||
char peekChar = stream_in.Peek();
|
char peekChar = stream_in.Peek();
|
||||||
char getChar = stream_in.GetC();
|
char getChar = stream_in.GetC();
|
||||||
|
if (stream_in.LastRead() == 1)
|
||||||
CPPUNIT_ASSERT(peekChar == getChar);
|
CPPUNIT_ASSERT(peekChar == getChar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -313,7 +314,7 @@ protected:
|
|||||||
//CPPUNIT_ASSERT(stream_out.SeekO(-2, wxFromEnd) == (off_t)stream_in.GetSize()-2);
|
//CPPUNIT_ASSERT(stream_out.SeekO(-2, wxFromEnd) == (off_t)stream_in.GetSize()-2);
|
||||||
CPPUNIT_ASSERT(stream_out.SeekO(-2, wxFromEnd) != wxInvalidOffset);
|
CPPUNIT_ASSERT(stream_out.SeekO(-2, wxFromEnd) != wxInvalidOffset);
|
||||||
// Go beyond the stream size.
|
// Go beyond the stream size.
|
||||||
CPPUNIT_ASSERT(stream_out.SeekO(10, wxFromCurrent) == wxInvalidOffset);
|
CPPUNIT_ASSERT((stream_out.SeekO(10, wxFromCurrent) == wxInvalidOffset) == m_bSeekInvalidBeyondEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Just try to perform a TellO() on the output stream.
|
// Just try to perform a TellO() on the output stream.
|
||||||
@@ -349,6 +350,8 @@ protected:
|
|||||||
// Default false.
|
// Default false.
|
||||||
bool m_bSimpleTellOTest; // if true, no SeekO will be used by the TellI test.
|
bool m_bSimpleTellOTest; // if true, no SeekO will be used by the TellI test.
|
||||||
// Default false.
|
// Default false.
|
||||||
|
bool m_bSeekInvalidBeyondEnd; // if true a SeekI|O beyond the end of the stream should return wxInvalidOffset
|
||||||
|
// Default true.
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TStreamIn &CreateInStream()
|
TStreamIn &CreateInStream()
|
||||||
|
@@ -84,7 +84,7 @@ private:
|
|||||||
|
|
||||||
ffileStream::ffileStream()
|
ffileStream::ffileStream()
|
||||||
{
|
{
|
||||||
/* Nothing extra */
|
m_bSeekInvalidBeyondEnd = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ffileStream::~ffileStream()
|
ffileStream::~ffileStream()
|
||||||
|
@@ -84,7 +84,7 @@ private:
|
|||||||
|
|
||||||
fileStream::fileStream()
|
fileStream::fileStream()
|
||||||
{
|
{
|
||||||
/* Nothing extra */
|
m_bSeekInvalidBeyondEnd = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fileStream::~fileStream()
|
fileStream::~fileStream()
|
||||||
|
@@ -34,6 +34,9 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace CppUnit;
|
using namespace CppUnit;
|
||||||
|
|
||||||
|
#define WXTEST_WITH_GZIP_CONDITION(testMethod) \
|
||||||
|
WXTEST_WITH_CONDITION( COMPOSE_TEST_NAME(zlibStream), wxZlibInputStream::CanHandleGZip() && wxZlibOutputStream::CanHandleGZip(), testMethod )
|
||||||
|
|
||||||
#define DATABUFFER_SIZE 1024
|
#define DATABUFFER_SIZE 1024
|
||||||
|
|
||||||
static const wxString FILENAME_GZ = _T("zlibtest.gz");
|
static const wxString FILENAME_GZ = _T("zlibtest.gz");
|
||||||
@@ -41,7 +44,7 @@ static const wxString FILENAME_GZ = _T("zlibtest.gz");
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// The test case
|
// The test case
|
||||||
//
|
//
|
||||||
// Try to fully test wxZlibInputStream and wxFileOutputStream
|
// Try to fully test wxZlibInputStream and wxZlibOutputStream
|
||||||
|
|
||||||
class zlibStream : public BaseStreamTestCase<wxZlibInputStream, wxZlibOutputStream>
|
class zlibStream : public BaseStreamTestCase<wxZlibInputStream, wxZlibOutputStream>
|
||||||
{
|
{
|
||||||
@@ -76,11 +79,11 @@ public:
|
|||||||
CPPUNIT_TEST(TestStream_ZLib_NoComp);
|
CPPUNIT_TEST(TestStream_ZLib_NoComp);
|
||||||
CPPUNIT_TEST(TestStream_ZLib_SpeedComp);
|
CPPUNIT_TEST(TestStream_ZLib_SpeedComp);
|
||||||
CPPUNIT_TEST(TestStream_ZLib_BestComp);
|
CPPUNIT_TEST(TestStream_ZLib_BestComp);
|
||||||
CPPUNIT_TEST(TestStream_GZip_Default);
|
WXTEST_WITH_GZIP_CONDITION(TestStream_GZip_Default);
|
||||||
CPPUNIT_TEST(TestStream_GZip_NoComp);
|
WXTEST_WITH_GZIP_CONDITION(TestStream_GZip_NoComp);
|
||||||
CPPUNIT_TEST(TestStream_GZip_SpeedComp);
|
WXTEST_WITH_GZIP_CONDITION(TestStream_GZip_SpeedComp);
|
||||||
CPPUNIT_TEST(TestStream_GZip_BestComp);
|
WXTEST_WITH_GZIP_CONDITION(TestStream_GZip_BestComp);
|
||||||
CPPUNIT_TEST(TestStream_ZLibGZip);
|
WXTEST_WITH_GZIP_CONDITION(TestStream_ZLibGZip);
|
||||||
CPPUNIT_TEST(Decompress_BadData);
|
CPPUNIT_TEST(Decompress_BadData);
|
||||||
CPPUNIT_TEST(Decompress_wx24Data);
|
CPPUNIT_TEST(Decompress_wx24Data);
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
Reference in New Issue
Block a user