From fbd23270e3d0552b223ffb6f8b509092d7c11520 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 7 Mar 2021 20:32:26 +0100 Subject: [PATCH] Remove CppUnit boilerplate from wxModule unit test Also use wxString instead of fixed size char array and wxStrcat(). --- tests/misc/module.cpp | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/tests/misc/module.cpp b/tests/misc/module.cpp index efb8d64cf7..d05b85ec82 100644 --- a/tests/misc/module.cpp +++ b/tests/misc/module.cpp @@ -19,12 +19,12 @@ // test classes derived from wxModule // ---------------------------------------------------------------------------- -char g_strLoadOrder[256] = "\0"; +wxString g_strLoadOrder; class Module : public wxModule { protected: - virtual bool OnInit() wxOVERRIDE { wxStrcat(g_strLoadOrder, GetClassInfo()->GetClassName()); return true; } + virtual bool OnInit() wxOVERRIDE { g_strLoadOrder += GetClassInfo()->GetClassName(); return true; } virtual void OnExit() wxOVERRIDE { } }; @@ -86,32 +86,11 @@ ModuleD::ModuleD() } // ---------------------------------------------------------------------------- -// test class +// tests themselves // ---------------------------------------------------------------------------- -class ModuleTestCase : public CppUnit::TestCase -{ -public: - ModuleTestCase() { } - -private: - CPPUNIT_TEST_SUITE( ModuleTestCase ); - CPPUNIT_TEST( LoadOrder ); - CPPUNIT_TEST_SUITE_END(); - - void LoadOrder(); - wxDECLARE_NO_COPY_CLASS(ModuleTestCase); -}; - -// register in the unnamed registry so that these tests are run by default -CPPUNIT_TEST_SUITE_REGISTRATION( ModuleTestCase ); - -// also include in its own registry so that these tests can be run alone -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ModuleTestCase, "ModuleTestCase" ); - -void ModuleTestCase::LoadOrder() +TEST_CASE("wxModule::LoadOrder", "[module]") { // module D is the only one with no dependencies and so should load as first (and so on): - CPPUNIT_ASSERT_EQUAL( std::string("ModuleDModuleCModuleBModuleA"), - g_strLoadOrder ); + CHECK( g_strLoadOrder == "ModuleDModuleCModuleBModuleA" ); }