From c54b6110939196184049507e265fef4c2b9d9364 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 31 Oct 2017 22:04:12 +0100 Subject: [PATCH] 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. --- tests/streams/bstream.h | 31 +++++++++++++++++++++++++------ tests/streams/zlibstream.cpp | 6 +++--- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/tests/streams/bstream.h b/tests/streams/bstream.h index b1fe8aa326..51a27966c6 100644 --- a/tests/streams/bstream.h +++ b/tests/streams/bstream.h @@ -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() { diff --git a/tests/streams/zlibstream.cpp b/tests/streams/zlibstream.cpp index d11f1809d3..bc0275afa2 100644 --- a/tests/streams/zlibstream.cpp +++ b/tests/streams/zlibstream.cpp @@ -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.