Remove CppUnit boilerplate from wxModule unit test

Also use wxString instead of fixed size char array and wxStrcat().
This commit is contained in:
Vadim Zeitlin
2021-03-07 20:32:26 +01:00
parent e10e721120
commit fbd23270e3

View File

@@ -19,12 +19,12 @@
// test classes derived from wxModule // test classes derived from wxModule
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
char g_strLoadOrder[256] = "\0"; wxString g_strLoadOrder;
class Module : public wxModule class Module : public wxModule
{ {
protected: 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 { } virtual void OnExit() wxOVERRIDE { }
}; };
@@ -86,32 +86,11 @@ ModuleD::ModuleD()
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// test class // tests themselves
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class ModuleTestCase : public CppUnit::TestCase TEST_CASE("wxModule::LoadOrder", "[module]")
{
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()
{ {
// module D is the only one with no dependencies and so should load as first (and so on): // module D is the only one with no dependencies and so should load as first (and so on):
CPPUNIT_ASSERT_EQUAL( std::string("ModuleDModuleCModuleBModuleA"), CHECK( g_strLoadOrder == "ModuleDModuleCModuleBModuleA" );
g_strLoadOrder );
} }