Replace few uses of CPPUNIT_TEST_FAIL with just CPPUNIT_TEST

Use positive tests really checking for whatever we want to check (that
the stream is not seekable in this particular case) instead of just
checking that the test fails, for whatever reason -- which might not be
at all the reason for which we expect it to fail.
This commit is contained in:
Vadim Zeitlin
2017-10-31 22:04:12 +01:00
parent b8c9cd3528
commit c54b611093
2 changed files with 28 additions and 9 deletions

View File

@@ -81,11 +81,18 @@ protected:
CPPUNIT_ASSERT(!stream_in.Eof());
// Size should be greater than zero.
// Note: streams not supporting this should register this test
// with CPPUNIT_TEST_FAIL instead of CPPUNIT_TEST.
CPPUNIT_ASSERT(stream_in.GetSize() != 0);
}
// The variant for non-seekable streams.
void Input_GetSizeFail()
{
CleanupHelper cleanup(this);
const TStreamIn &stream_in = CreateInStream();
CPPUNIT_ASSERT(stream_in.GetSize() == 0);
}
// Just try to perform a GetC() on the input stream.
void Input_GetC()
{
@@ -199,8 +206,6 @@ protected:
CPPUNIT_ASSERT(!stream_in.Eof());
// Try to Seek in the stream...
// Note: streams not supporting this should register this test
// with CPPUNIT_TEST_FAIL instead of CPPUNIT_TEST.
CPPUNIT_ASSERT_EQUAL(2, stream_in.SeekI(2, wxFromStart));
CPPUNIT_ASSERT_EQUAL(4, stream_in.SeekI(2, wxFromCurrent));
// Not sure the following line is correct, so test it differently.
@@ -210,6 +215,14 @@ protected:
CPPUNIT_ASSERT((stream_in.SeekI(10, wxFromCurrent) == wxInvalidOffset) == m_bSeekInvalidBeyondEnd);
}
void Input_SeekIFail()
{
CleanupHelper cleanup(this);
TStreamIn &stream_in = CreateInStream();
CPPUNIT_ASSERT( !stream_in.IsSeekable() );
}
// Just try to perform a TellI() on the input stream.
void Input_TellI()
{
@@ -340,8 +353,6 @@ protected:
(void)stream_out.Write(buf, 10);
// Try to Seek in the stream...
// Note: streams not supporting this should register this test
// with CPPUNIT_TEST_FAIL instead of CPPUNIT_TEST.
CPPUNIT_ASSERT_EQUAL(2, stream_out.SeekO(2, wxFromStart));
CPPUNIT_ASSERT_EQUAL(4, stream_out.SeekO(2, wxFromCurrent));
// Not sure the following line is correct, so test it differently.
@@ -351,6 +362,14 @@ protected:
CPPUNIT_ASSERT((stream_out.SeekO(10, wxFromCurrent) == wxInvalidOffset) == m_bSeekInvalidBeyondEnd);
}
void Output_SeekOFail()
{
CleanupHelper cleanup(this);
TStreamOut &stream_out = CreateOutStream();
CPPUNIT_ASSERT( !stream_out.IsSeekable() );
}
// Just try to perform a TellO() on the output stream.
void Output_TellO()
{

View File

@@ -46,13 +46,13 @@ public:
CPPUNIT_TEST_SUITE(zlibStream);
// Base class stream tests the zlibstream supports.
CPPUNIT_TEST_FAIL(Input_GetSize);
CPPUNIT_TEST(Input_GetSizeFail);
CPPUNIT_TEST(Input_GetC);
CPPUNIT_TEST(Input_Read);
CPPUNIT_TEST(Input_Eof);
CPPUNIT_TEST(Input_LastRead);
CPPUNIT_TEST(Input_CanRead);
CPPUNIT_TEST_FAIL(Input_SeekI);
CPPUNIT_TEST(Input_SeekIFail);
CPPUNIT_TEST(Input_TellI);
CPPUNIT_TEST(Input_Peek);
CPPUNIT_TEST(Input_Ungetch);
@@ -60,7 +60,7 @@ public:
CPPUNIT_TEST(Output_PutC);
CPPUNIT_TEST(Output_Write);
CPPUNIT_TEST(Output_LastWrite);
CPPUNIT_TEST_FAIL(Output_SeekO);
CPPUNIT_TEST(Output_SeekOFail);
CPPUNIT_TEST(Output_TellO);
// Other test specific for zlib stream test case.