8000 Add UNITTEST_ prefixes to remaining macros · unittest-cpp/unittest-cpp@df386f1 · GitHub
[go: up one dir, main page]

Skip to content

Commit df386f1

Browse files
committed
Add UNITTEST_ prefixes to remaining macros
TEST, SUITE, and REQUIRE macros now have UNITTEST_ and UNITTEST_IMPL_ prefixes like the others, completing the set.
1 parent c96bf52 commit df386f1

File tree

3 files changed

+39
-28
lines changed

3 files changed

+39
-28
lines changed

UnitTest++/RequireMacros.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33

44
#include "RequiredCheckTestReporter.h"
55

6-
#ifdef REQUIRE
7-
#error UnitTest++ redefines REQUIRE
8-
#endif
6+
#define UNITTEST_REQUIRE for(UnitTest::RequiredCheckTestReporter decoratedReporter(*UnitTest::CurrentTest::Results()); decoratedReporter.Next(); )
97

10-
#define REQUIRE for(UnitTest::RequiredCheckTestReporter decoratedReporter(*UnitTest::CurrentTest::Results()); decoratedReporter.Next(); )
8+
#if UNITTEST_ENABLE_SHORT_MACROS
9+
#ifdef REQUIRE
10+
#error REQUIRE already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_REQUIRE instead
11+
#else
12+
#define REQUIRE UNITTEST_REQUIRE
13+
#endif
14+
#endif
1115

1216
#endif

UnitTest++/TestMacros.h

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,7 @@
1515
#include "Posix/SignalTranslator.h"
1616
#endif
1717

18-
#ifdef TEST
19-
#error UnitTest++ redefines TEST
20-
#endif
21-
22-
#ifdef TEST_EX
23-
#error UnitTest++ redefines TEST_EX
24-
#endif
25-
26-
#ifdef TEST_FIXTURE_EX
27-
#error UnitTest++ redefines TEST_FIXTURE_EX
28-
#endif
29-
30-
#define SUITE(Name) \
18+
#define UNITTEST_SUITE(Name) \
3119
namespace Suite ## Name { \
3220
namespace UnitTestSuite { \
3321
inline char const* GetSuiteName () { \
@@ -37,7 +25,7 @@
3725
} \
3826
namespace Suite ## Name
3927

40-
#define TEST_EX(Name, List) \
28+
#define UNITTEST_IMPL_TEST(Name, List) \
4129
class Test ## Name : public UnitTest::Test \
4230
{ \
4331
public: \
@@ -51,10 +39,10 @@
5139
void Test ## Name::RunImpl() const
5240

5341

54-
#define TEST(Name) TEST_EX(Name, UnitTest::Test::GetTestList())
42+
#define UNITTEST_TEST(Name) UNITTEST_IMPL_TEST(Name, UnitTest::Test::GetTestList())
5543

5644

57-
#define TEST_FIXTURE_EX(Fixture, Name, List) \
45+
#define UNITTEST_IMPL_TEST_FIXTURE(Fixture, Name, List) \
5846
class Fixture ## Name ## Helper : public Fixture \
5947
{ \
6048
public: \
@@ -111,7 +99,26 @@
11199
} \
112100
void Fixture ## Name ## Helper::RunImpl()
113101

114-
#define TEST_FIXTURE(Fixture,Name) TEST_FIXTURE_EX(Fixture, Name, UnitTest::Test::GetTestList())
102+
#define UNITTEST_TEST_FIXTURE(Fixture,Name) UNITTEST_IMPL_TEST_FIXTURE(Fixture, Name, UnitTest::Test::GetTestList())
103+
104+
#if UNITTEST_ENABLE_SHORT_MACROS
105+
#ifdef SUITE
106+
#error SUITE already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_SUITE instead
107+
#else
108+
#define SUITE UNITTEST_SUITE
109+
#endif
115110

111+
#ifdef TEST
112+
#error TEST already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_TEST instead
113+
#else
114+
#define TEST UNITTEST_TEST
115+
#endif
116+
117+
#ifdef TEST_FIXTURE
118+
#error TEST_FIXTURE already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_TEST_FIXTURE instead
119+
#else
120+
#define TEST_FIXTURE UNITTEST_TEST_FIXTURE
121+
#endif
122+
#endif
116123

117124
#endif

tests/TestTestMacros.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ using namespace std;
4646
namespace {
4747

4848
TestList list1;
49-
TEST_EX(DummyTest, list1)
49+
UNITTEST_IMPL_TEST(DummyTest, list1)
5050
{}
5151

5252
TEST (TestsAreAddedToTheListThroughMacro)
@@ -69,7 +69,7 @@ namespace {
6969
};
7070

7171
TestList list2;
72-
TEST_FIXTURE_EX(ThrowingThingie, DummyTestName, list2)
72+
UNITTEST_IMPL_TEST_FIXTURE(ThrowingThingie, DummyTestName, list2)
7373
{}
7474

7575
TEST (ExceptionsInFixtureAreReportedAsHappeningInTheFixture)
@@ -113,7 +113,7 @@ namespace {
113113
}
114114

115115
TestList macroTestList1;
116-
TEST_EX(MacroTestHelper1, macroTestList1)
116+
UNITTEST_IMPL_TEST(MacroTestHelper1, macroTestList1)
117117
{}
118118

119119
TEST(TestAddedWithTEST_EXMacroGetsDefaultSuite)
@@ -124,7 +124,7 @@ namespace {
124124
}
125125

126126
TestList macroTestList2;
127 1E79 -
TEST_FIXTURE_EX(DummyFixture, MacroTestHelper2, macroTestList2)
127+
UNITTEST_IMPL_TEST_FIXTURE(DummyFixture, MacroTestHelper2, macroTestList2)
128128
{}
129129

130130
TEST(TestAddedWithTEST_FIXTURE_EXMacroGetsDefaultSuite)
@@ -144,7 +144,7 @@ namespace {
144144
};
145145

146146
TestList throwingFixtureTestList1;
147-
TEST_FIXTURE_EX(FixtureCtorThrows, FixtureCtorThrowsTestName, throwingFixtureTestList1)
147+
UNITTEST_IMPL_TEST_FIXTURE(FixtureCtorThrows, FixtureCtorThrowsTestName, throwingFixtureTestList1)
148148
{}
149149

150150
TEST(FixturesWithThrowingCtorsAreFailures)
@@ -170,7 +170,7 @@ namespace {
170170
};
171171

172172
TestList throwingFixtureTestList2;
173-
TEST_FIXTURE_EX(FixtureDtorThrows, FixtureDtorThrowsTestName, throwingFixtureTestList2)
173+
UNITTEST_IMPL_TEST_FIXTURE(FixtureDtorThrows, FixtureDtorThrowsTestName, throwingFixtureTestList2)
174174
{}
175175

176176
TEST(FixturesWithThrowingDtorsAreFailures)
@@ -200,7 +200,7 @@ namespace {
200200
};
201201

202202
TestList ctorAssertFixtureTestList;
203-
TEST_FIXTURE_EX(FixtureCtorAsserts, CorrectlyReportsAssertFailureInCtor, ctorAssertFixtureTestList)
203+
UNITTEST_IMPL_TEST_FIXTURE(FixtureCtorAsserts, CorrectlyReportsAssertFailureInCtor, ctorAssertFixtureTestList)
204204
{}
205205

206206
TEST(CorrectlyReportsFixturesWithCtorsThatAssert)

0 commit comments

Comments
 (0)
0