Add a convenient wxREGISTER_UNIT_TEST() macro.

This macro can be used to easily register a test following a standard naming
convention in both the global test suite and the test suite with the same name
as this test instead of having to use 2 different cppunit macros to do the
same thing.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65514 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2010-09-11 10:18:05 +00:00
parent daf9622e38
commit 8cdd00f29f

View File

@ -92,3 +92,20 @@ private:
const char * const m_locOld;
wxDECLARE_NO_COPY_CLASS(CLocaleSetter);
};
// Macro that can be used to register the test with the given name in both the
// global unnamed registry so that it is ran by default and a registry with the
// same name as this test to allow running just this test individually.
//
// Notice that the name shouldn't include the "TestCase" suffix, it's added
// automatically by this macro.
//
// Implementation note: CPPUNIT_TEST_SUITE_[NAMED_]REGISTRATION macros can't be
// used here because they both declare the variable with the same name (as the
// "unique" name they generate is based on the line number which is the same
// for both calls inside the macro), so we need to do it manually.
#define wxREGISTER_UNIT_TEST(name) \
static CPPUNIT_NS::AutoRegisterSuite< name##TestCase > \
CPPUNIT_MAKE_UNIQUE_NAME( autoRegisterRegistry__ ); \
static CPPUNIT_NS::AutoRegisterSuite< name##TestCase > \
CPPUNIT_MAKE_UNIQUE_NAME( autoRegisterNamedRegistry__ )(#name "TestCase")