From a973d02c9fecebc0d2f7f823d9cdbd9c428ac100 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 1 May 2020 15:06:05 +0200 Subject: [PATCH] Get rid of CppUnit cruft in wxFileSystem test case Use CATCH macros directly and define separate test cases instead of using a useless FileSystemTestCase class. Also add INFO() macros to provide information about the context in case of test failure. No real changes. --- tests/filesys/filesystest.cpp | 49 ++++++++++------------------------- 1 file changed, 13 insertions(+), 36 deletions(-) diff --git a/tests/filesys/filesystest.cpp b/tests/filesys/filesystest.cpp index 4f58313de4..06d07a0952 100644 --- a/tests/filesys/filesystest.cpp +++ b/tests/filesys/filesystest.cpp @@ -48,35 +48,10 @@ public: // ---------------------------------------------------------------------------- -// test class +// tests themselves // ---------------------------------------------------------------------------- -class FileSystemTestCase : public CppUnit::TestCase -{ -public: - FileSystemTestCase() { } - -private: - CPPUNIT_TEST_SUITE( FileSystemTestCase ); - CPPUNIT_TEST( UrlParsing ); - CPPUNIT_TEST( FileNameToUrlConversion ); - CPPUNIT_TEST( UnicodeFileNameToUrlConversion ); - CPPUNIT_TEST_SUITE_END(); - - void UrlParsing(); - void FileNameToUrlConversion(); - void UnicodeFileNameToUrlConversion(); - - wxDECLARE_NO_COPY_CLASS(FileSystemTestCase); -}; - -// register in the unnamed registry so that these tests are run by default -CPPUNIT_TEST_SUITE_REGISTRATION( FileSystemTestCase ); - -// also include in its own registry so that these tests can be run alone -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( FileSystemTestCase, "FileSystemTestCase" ); - -void FileSystemTestCase::UrlParsing() +TEST_CASE("wxFileSystem::URLParsing", "[filesys][url][parse]") { static const struct Data { @@ -151,14 +126,15 @@ void FileSystemTestCase::UrlParsing() for ( size_t n = 0; n < WXSIZEOF(data); n++ ) { const Data& d = data[n]; - CPPUNIT_ASSERT_EQUAL( d.protocol, tst.Protocol(d.url) ); - CPPUNIT_ASSERT_EQUAL( d.left, tst.LeftLocation(d.url) ); - CPPUNIT_ASSERT_EQUAL( d.right, tst.RightLocation(d.url) ); - CPPUNIT_ASSERT_EQUAL( d.anchor, tst.Anchor(d.url) ); + INFO( "Testing URL " << wxString(d.url) ); + CHECK( tst.Protocol(d.url) == d.protocol ); + CHECK( tst.LeftLocation(d.url) == d.left ); + CHECK( tst.RightLocation(d.url) == d.right ); + CHECK( tst.Anchor(d.url) == d.anchor ); } } -void FileSystemTestCase::FileNameToUrlConversion() +TEST_CASE("wxFileSystem::FileNameToUrlConversion", "[filesys][url][filename]") { const static struct Data { const wxChar *input, *expected; @@ -179,12 +155,13 @@ void FileSystemTestCase::FileNameToUrlConversion() wxFileName fn1(d.input); wxString url1 = wxFileSystem::FileNameToURL(fn1); - CPPUNIT_ASSERT_EQUAL( d.expected, url1 ); - CPPUNIT_ASSERT( fn1.SameAs(wxFileName::URLToFileName(url1)) ); + INFO( "Testing URL " << wxString(d.input) ); + CHECK( url1 == d.expected ); + CHECK( fn1.SameAs(wxFileName::URLToFileName(url1)) ); } } -void FileSystemTestCase::UnicodeFileNameToUrlConversion() +TEST_CASE("wxFileSystem::UnicodeFileNameToUrlConversion", "[filesys][url][filename][unicode]") { const unsigned char filename_utf8[] = { 0x4b, 0x72, 0xc3, 0xa1, 0x73, 0x79, 0x50, 0xc5, @@ -196,7 +173,7 @@ void FileSystemTestCase::UnicodeFileNameToUrlConversion() wxString url = wxFileSystem::FileNameToURL(filename); - CPPUNIT_ASSERT( filename.SameAs(wxFileName::URLToFileName(url)) ); + CHECK( filename.SameAs(wxFileName::URLToFileName(url)) ); } #endif // wxUSE_FILESYSTEM