summaryrefslogtreecommitdiff
path: root/src/mongo/unittest/death_test.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/unittest/death_test.h')
-rw-r--r--src/mongo/unittest/death_test.h62
1 files changed, 34 insertions, 28 deletions
diff --git a/src/mongo/unittest/death_test.h b/src/mongo/unittest/death_test.h
index 5aff0c39cd4..587d96aca7a 100644
--- a/src/mongo/unittest/death_test.h
+++ b/src/mongo/unittest/death_test.h
@@ -45,18 +45,20 @@
* in your death test, start them in the test body, or use DEATH_TEST_F and start them
* in the setUp() method of the fixture.
*/
-#define DEATH_TEST(CASE_NAME, TEST_NAME, MATCH_EXPR) \
- class _TEST_TYPE_NAME(CASE_NAME, TEST_NAME) : public ::mongo::unittest::Test { \
- private: \
- virtual void _doTest(); \
- \
- static const RegistrationAgent<::mongo::unittest::DeathTest< \
- _TEST_TYPE_NAME(CASE_NAME, TEST_NAME)>> _agent; \
- }; \
- const ::mongo::unittest::Test::RegistrationAgent< \
- ::mongo::unittest::DeathTest<_TEST_TYPE_NAME(CASE_NAME, TEST_NAME)>> \
- _TEST_TYPE_NAME(CASE_NAME, TEST_NAME)::_agent(#CASE_NAME, #TEST_NAME); \
- std::string getDeathTestPattern(_TEST_TYPE_NAME(CASE_NAME, TEST_NAME)*) { return MATCH_EXPR; } \
+#define DEATH_TEST(CASE_NAME, TEST_NAME, MATCH_EXPR) \
+ class _TEST_TYPE_NAME(CASE_NAME, TEST_NAME) : public ::mongo::unittest::Test { \
+ private: \
+ virtual void _doTest(); \
+ \
+ static const RegistrationAgent< \
+ ::mongo::unittest::DeathTest<_TEST_TYPE_NAME(CASE_NAME, TEST_NAME)>> _agent; \
+ }; \
+ const ::mongo::unittest::Test::RegistrationAgent<::mongo::unittest::DeathTest<_TEST_TYPE_NAME( \
+ CASE_NAME, TEST_NAME)>> _TEST_TYPE_NAME(CASE_NAME, TEST_NAME)::_agent(#CASE_NAME, \
+ #TEST_NAME); \
+ std::string getDeathTestPattern(_TEST_TYPE_NAME(CASE_NAME, TEST_NAME)*) { \
+ return MATCH_EXPR; \
+ } \
void _TEST_TYPE_NAME(CASE_NAME, TEST_NAME)::_doTest()
/**
@@ -65,27 +67,28 @@
*
* See description of DEATH_TEST for more details on death tests.
*/
-#define DEATH_TEST_F(FIXTURE_NAME, TEST_NAME, MATCH_EXPR) \
- class _TEST_TYPE_NAME(FIXTURE_NAME, TEST_NAME) : public FIXTURE_NAME { \
- private: \
- virtual void _doTest(); \
- \
- static const RegistrationAgent<::mongo::unittest::DeathTest< \
- _TEST_TYPE_NAME(FIXTURE_NAME, TEST_NAME)>> _agent; \
- }; \
- const ::mongo::unittest::Test::RegistrationAgent< \
- ::mongo::unittest::DeathTest<_TEST_TYPE_NAME(FIXTURE_NAME, TEST_NAME)>> \
- _TEST_TYPE_NAME(FIXTURE_NAME, TEST_NAME)::_agent(#FIXTURE_NAME, #TEST_NAME); \
- std::string getDeathTestPattern(_TEST_TYPE_NAME(FIXTURE_NAME, TEST_NAME)*) { \
- return MATCH_EXPR; \
- } \
- void _TEST_TYPE_NAME(FIXTURE_NAME, TEST_NAME)::_doTest()
+#define DEATH_TEST_F(FIXTURE_NAME, TEST_NAME, MATCH_EXPR) \
+ class _TEST_TYPE_NAME(FIXTURE_NAME, TEST_NAME) : public FIXTURE_NAME { \
+ private: \
+ virtual void _doTest(); \
+ \
+ static const RegistrationAgent< \
+ ::mongo::unittest::DeathTest<_TEST_TYPE_NAME(FIXTURE_NAME, TEST_NAME)>> _agent; \
+ }; \
+ const ::mongo::unittest::Test::RegistrationAgent<::mongo::unittest::DeathTest<_TEST_TYPE_NAME( \
+ FIXTURE_NAME, TEST_NAME)>> _TEST_TYPE_NAME(FIXTURE_NAME, TEST_NAME)::_agent(#FIXTURE_NAME, \
+ #TEST_NAME); \
+ std::string getDeathTestPattern(_TEST_TYPE_NAME(FIXTURE_NAME, TEST_NAME)*) { \
+ return MATCH_EXPR; \
+ } \
+ void _TEST_TYPE_NAME(FIXTURE_NAME, TEST_NAME)::_doTest()
namespace mongo {
namespace unittest {
class DeathTestImpl : public Test {
MONGO_DISALLOW_COPYING(DeathTestImpl);
+
protected:
DeathTestImpl(std::unique_ptr<Test> test);
@@ -101,8 +104,11 @@ public:
static const std::string pattern;
DeathTest() : DeathTestImpl(stdx::make_unique<T>()) {}
+
private:
- std::string getPattern() override { return getDeathTestPattern(static_cast<T*>(nullptr)); }
+ std::string getPattern() override {
+ return getDeathTestPattern(static_cast<T*>(nullptr));
+ }
};
} // namespace unittest