From b48bd9852ecc3f621c619c7570b58cb205217cc1 Mon Sep 17 00:00:00 2001 From: Gabriel Schlozer Date: Thu, 25 Aug 2016 17:44:12 +0200 Subject: [PATCH] added long/short macro --- UnitTest++/ParameterizedMacros.h | 20 +++++++++++++++++--- tests/TestLongMacros.cpp | 4 +++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/UnitTest++/ParameterizedMacros.h b/UnitTest++/ParameterizedMacros.h index 06f2fa1..37a71bc 100644 --- a/UnitTest++/ParameterizedMacros.h +++ b/UnitTest++/ParameterizedMacros.h @@ -4,7 +4,7 @@ #include "TestParameter.h" -#define SET_TEST_PARAMETER_LISTENER(Type, Name, ListenerPtr, SetUpBody) \ +#define UNITTEST_SET_TEST_PARAMETER_LISTENER(Type, Name, ListenerPtr, SetUpBody) \ class ParameterizedCreator##Name \ { \ public: \ @@ -22,8 +22,22 @@ static UnitTest::TestParameter & Name(parameterizedCreator##Name##Instance.globalInstance) -#define SET_TEST_PARAMETER(Type, Name, SetUpBody) \ - SET_TEST_PARAMETER_LISTENER(Type, Name, nullptr, SetUpBody) +#define UNITTEST_SET_TEST_PARAMETER(Type, Name, SetUpBody) \ + UNITTEST_SET_TEST_PARAMETER_LISTENER(Type, Name, nullptr, SetUpBody) +#ifndef UNITTEST_DISABLE_SHORT_MACROS + #ifdef SET_TEST_PARAMETER_LISTENER + #error SET_TEST_PARAMETER_LISTENER already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_SET_TEST_PARAMETER_LISTENER instead + #else + #define SET_TEST_PARAMETER_LISTENER UNITTEST_SET_TEST_PARAMETER_LISTENER + #endif + + #ifdef SET_TEST_PARAMETER + #error SET_TEST_PARAMETER already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_SET_TEST_PARAMETER instead + #else + #define SET_TEST_PARAMETER UNITTEST_SET_TEST_PARAMETER + #endif +#endif + #endif \ No newline at end of file diff --git a/tests/TestLongMacros.cpp b/tests/TestLongMacros.cpp index 6720a97..6c58830 100644 --- a/tests/TestLongMacros.cpp +++ b/tests/TestLongMacros.cpp @@ -37,7 +37,9 @@ UNITTEST_SUITE(LongMacros) defined(SUITE) || \ defined(TEST) || \ defined(TEST_FIXTURE) || \ - defined(REQUIRE) + defined(REQUIRE) || \ + defined(SET_TEST_PARAMETER_LISTENER) || \ + defined(SET_TEST_PARAMETER) UNITTEST_CHECK(false); #endif