mirror of
https://github.com/unittest-cpp/unittest-cpp
synced 2026-09-26 16:19:30 +03:00
Add UNITTEST_ prefixes to remaining macros
TEST, SUITE, and REQUIRE macros now have UNITTEST_ and UNITTEST_IMPL_ prefixes like the others, completing the set.
This commit is contained in:
parent
c96bf52613
commit
df386f189f
3 changed files with 39 additions and 28 deletions
|
|
@ -3,10 +3,14 @@
|
|||
|
||||
#include "RequiredCheckTestReporter.h"
|
||||
|
||||
#ifdef REQUIRE
|
||||
#error UnitTest++ redefines REQUIRE
|
||||
#define UNITTEST_REQUIRE for(UnitTest::RequiredCheckTestReporter decoratedReporter(*UnitTest::CurrentTest::Results()); decoratedReporter.Next(); )
|
||||
|
||||
#if UNITTEST_ENABLE_SHORT_MACROS
|
||||
#ifdef REQUIRE
|
||||
#error REQUIRE already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_REQUIRE instead
|
||||
#else
|
||||
#define REQUIRE UNITTEST_REQUIRE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define REQUIRE for(UnitTest::RequiredCheckTestReporter decoratedReporter(*UnitTest::CurrentTest::Results()); decoratedReporter.Next(); )
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -15,19 +15,7 @@
|
|||
#include "Posix/SignalTranslator.h"
|
||||
#endif
|
||||
|
||||
#ifdef TEST
|
||||
#error UnitTest++ redefines TEST
|
||||
#endif
|
||||
|
||||
#ifdef TEST_EX
|
||||
#error UnitTest++ redefines TEST_EX
|
||||
#endif
|
||||
|
||||
#ifdef TEST_FIXTURE_EX
|
||||
#error UnitTest++ redefines TEST_FIXTURE_EX
|
||||
#endif
|
||||
|
||||
#define SUITE(Name) \
|
||||
#define UNITTEST_SUITE(Name) \
|
||||
namespace Suite ## Name { \
|
||||
namespace UnitTestSuite { \
|
||||
inline char const* GetSuiteName () { \
|
||||
|
|
@ -37,7 +25,7 @@
|
|||
} \
|
||||
namespace Suite ## Name
|
||||
|
||||
#define TEST_EX(Name, List) \
|
||||
#define UNITTEST_IMPL_TEST(Name, List) \
|
||||
class Test ## Name : public UnitTest::Test \
|
||||
{ \
|
||||
public: \
|
||||
|
|
@ -51,10 +39,10 @@
|
|||
void Test ## Name::RunImpl() const
|
||||
|
||||
|
||||
#define TEST(Name) TEST_EX(Name, UnitTest::Test::GetTestList())
|
||||
#define UNITTEST_TEST(Name) UNITTEST_IMPL_TEST(Name, UnitTest::Test::GetTestList())
|
||||
|
||||
|
||||
#define TEST_FIXTURE_EX(Fixture, Name, List) \
|
||||
#define UNITTEST_IMPL_TEST_FIXTURE(Fixture, Name, List) \
|
||||
class Fixture ## Name ## Helper : public Fixture \
|
||||
{ \
|
||||
public: \
|
||||
|
|
@ -111,7 +99,26 @@
|
|||
} \
|
||||
void Fixture ## Name ## Helper::RunImpl()
|
||||
|
||||
#define TEST_FIXTURE(Fixture,Name) TEST_FIXTURE_EX(Fixture, Name, UnitTest::Test::GetTestList())
|
||||
#define UNITTEST_TEST_FIXTURE(Fixture,Name) UNITTEST_IMPL_TEST_FIXTURE(Fixture, Name, UnitTest::Test::GetTestList())
|
||||
|
||||
#if UNITTEST_ENABLE_SHORT_MACROS
|
||||
#ifdef SUITE
|
||||
#error SUITE already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_SUITE instead
|
||||
#else
|
||||
#define SUITE UNITTEST_SUITE
|
||||
#endif
|
||||
|
||||
#ifdef TEST
|
||||
#error TEST already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_TEST instead
|
||||
#else
|
||||
#define TEST UNITTEST_TEST
|
||||
#endif
|
||||
|
||||
#ifdef TEST_FIXTURE
|
||||
#error TEST_FIXTURE already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_TEST_FIXTURE instead
|
||||
#else
|
||||
#define TEST_FIXTURE UNITTEST_TEST_FIXTURE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ using namespace std;
|
|||
namespace {
|
||||
|
||||
TestList list1;
|
||||
TEST_EX(DummyTest, list1)
|
||||
UNITTEST_IMPL_TEST(DummyTest, list1)
|
||||
{}
|
||||
|
||||
TEST (TestsAreAddedToTheListThroughMacro)
|
||||
|
|
@ -69,7 +69,7 @@ namespace {
|
|||
};
|
||||
|
||||
TestList list2;
|
||||
TEST_FIXTURE_EX(ThrowingThingie, DummyTestName, list2)
|
||||
UNITTEST_IMPL_TEST_FIXTURE(ThrowingThingie, DummyTestName, list2)
|
||||
{}
|
||||
|
||||
TEST (ExceptionsInFixtureAreReportedAsHappeningInTheFixture)
|
||||
|
|
@ -113,7 +113,7 @@ namespace {
|
|||
}
|
||||
|
||||
TestList macroTestList1;
|
||||
TEST_EX(MacroTestHelper1, macroTestList1)
|
||||
UNITTEST_IMPL_TEST(MacroTestHelper1, macroTestList1)
|
||||
{}
|
||||
|
||||
TEST(TestAddedWithTEST_EXMacroGetsDefaultSuite)
|
||||
|
|
@ -124,7 +124,7 @@ namespace {
|
|||
}
|
||||
|
||||
TestList macroTestList2;
|
||||
TEST_FIXTURE_EX(DummyFixture, MacroTestHelper2, macroTestList2)
|
||||
UNITTEST_IMPL_TEST_FIXTURE(DummyFixture, MacroTestHelper2, macroTestList2)
|
||||
{}
|
||||
|
||||
TEST(TestAddedWithTEST_FIXTURE_EXMacroGetsDefaultSuite)
|
||||
|
|
@ -144,7 +144,7 @@ namespace {
|
|||
};
|
||||
|
||||
TestList throwingFixtureTestList1;
|
||||
TEST_FIXTURE_EX(FixtureCtorThrows, FixtureCtorThrowsTestName, throwingFixtureTestList1)
|
||||
UNITTEST_IMPL_TEST_FIXTURE(FixtureCtorThrows, FixtureCtorThrowsTestName, throwingFixtureTestList1)
|
||||
{}
|
||||
|
||||
TEST(FixturesWithThrowingCtorsAreFailures)
|
||||
|
|
@ -170,7 +170,7 @@ namespace {
|
|||
};
|
||||
|
||||
TestList throwingFixtureTestList2;
|
||||
TEST_FIXTURE_EX(FixtureDtorThrows, FixtureDtorThrowsTestName, throwingFixtureTestList2)
|
||||
UNITTEST_IMPL_TEST_FIXTURE(FixtureDtorThrows, FixtureDtorThrowsTestName, throwingFixtureTestList2)
|
||||
{}
|
||||
|
||||
TEST(FixturesWithThrowingDtorsAreFailures)
|
||||
|
|
@ -200,7 +200,7 @@ namespace {
|
|||
};
|
||||
|
||||
TestList ctorAssertFixtureTestList;
|
||||
TEST_FIXTURE_EX(FixtureCtorAsserts, CorrectlyReportsAssertFailureInCtor, ctorAssertFixtureTestList)
|
||||
UNITTEST_IMPL_TEST_FIXTURE(FixtureCtorAsserts, CorrectlyReportsAssertFailureInCtor, ctorAssertFixtureTestList)
|
||||
{}
|
||||
|
||||
TEST(CorrectlyReportsFixturesWithCtorsThatAssert)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue