From 48145587c4c2dc4f1e07d83073e136336c81ce79 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 12 Oct 2018 21:34:07 +0200 Subject: extensions: add CPPUNIT_TEST_FIXTURE() This is similar to googletest's TEST_F() macro, allows to avoid spelling out the test name in a suite only once, not 3 times. Change-Id: I90804d271d046d8158678617d8db75ed6ca7c420 Reviewed-on: https://gerrit.libreoffice.org/61732 Reviewed-by: Markus Mohrhard Tested-by: Markus Mohrhard --- include/cppunit/extensions/HelperMacros.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'include/cppunit') diff --git a/include/cppunit/extensions/HelperMacros.h b/include/cppunit/extensions/HelperMacros.h index 4c30319..34be2ca 100644 --- a/include/cppunit/extensions/HelperMacros.h +++ b/include/cppunit/extensions/HelperMacros.h @@ -240,6 +240,29 @@ public: \ private: /* dummy typedef so that the macro can still end with ';'*/ \ typedef int CppUnitDummyTypedefForSemiColonEnding__ +/*! \brief Define test suite with a single test. + * + * This macro declares a new test suite with a single test and a single parent + * class. Use CPPUNIT_TEST_SUITE(), CPPUNIT_TEST() and + * CPPUNIT_TEST_SUITE_END() instead if you wish to include more tests in the + * suite. The benefit of using this macro is that you don't have to declare, + * register and define your test name manually, so you don't repeat yourself. + * + * \param TestClass Base class. This type \b MUST be derived from TestFixture. + * \param TestName Name of the test. + * \see CPPUNIT_TEST_SUITE, CPPUNIT_TEST, CPPUNIT_TEST_SUITE_END + */ +#define CPPUNIT_TEST_FIXTURE(TestClass, TestName) \ + class TestName : public TestClass \ + { \ + public: \ + void TestBody(); \ + CPPUNIT_TEST_SUITE(TestName); \ + CPPUNIT_TEST(TestBody); \ + CPPUNIT_TEST_SUITE_END(); \ + }; \ + CPPUNIT_TEST_SUITE_REGISTRATION(TestName); \ + void TestName::TestBody() /*! \brief Add a test to the suite (for custom test macro). * -- cgit v1.2.1