| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7b929df commit af60fbb
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -293,8 +293,8 @@ class GTEST_API_ KilledBySignal { | |||
| 293 | 293 | // statement is compiled but not executed, to ensure that | |
| 294 | 294 | // EXPECT_DEATH_IF_SUPPORTED compiles with a certain | |
| 295 | 295 | // parameter if and only if EXPECT_DEATH compiles with it. | |
| 296 | - // regex - A regex that a macro such as EXPECT_DEATH would use to test | ||
| 297 | - // the output of statement. This parameter has to be | ||
| 296 | + // regex_or_matcher - A regex that a macro such as EXPECT_DEATH would use | ||
| 297 | + // to test the output of statement. This parameter has to be | ||
| 298 | 298 | // compiled but not evaluated by this macro, to ensure that | |
| 299 | 299 | // this macro only accepts expressions that a macro such as | |
| 300 | 300 | // EXPECT_DEATH would accept. | |
@@ -311,13 +311,13 @@ class GTEST_API_ KilledBySignal { | |||
| 311 | 311 | // statement unconditionally returns or throws. The Message constructor at | |
| 312 | 312 | // the end allows the syntax of streaming additional messages into the | |
| 313 | 313 | // macro, for compilational compatibility with EXPECT_DEATH/ASSERT_DEATH. | |
| 314 | - #define GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, terminator) \ | ||
| 314 | + #define GTEST_UNSUPPORTED_DEATH_TEST(statement, regex_or_matcher, terminator) \ | ||
| 315 | 315 | GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ | |
| 316 | 316 | if (::testing::internal::AlwaysTrue()) { \ | |
| 317 | 317 | GTEST_LOG_(WARNING) << "Death tests are not supported on this platform.\n" \ | |
| 318 | 318 | << "Statement '" #statement "' cannot be verified."; \ | |
| 319 | 319 | } else if (::testing::internal::AlwaysFalse()) { \ | |
| 320 | - ::testing::internal::RE::PartialMatch(".*", (regex)); \ | ||
| 320 | + ::testing::internal::MakeDeathTestMatcher(regex_or_matcher); \ | ||
| 321 | 321 | GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ | |
| 322 | 322 | terminator; \ | |
| 323 | 323 | } else \ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -46,6 +46,7 @@ | |||
| 46 | 46 | ||
| 47 | 47 | #include "gtest/gtest-matchers.h" | |
| 48 | 48 | #include "gtest/internal/gtest-internal.h" | |
| 49 | + #include "gtest/internal/gtest-port.h" | ||
| 49 | 50 | ||
| 50 | 51 | GTEST_DECLARE_string_(internal_run_death_test); | |
| 51 | 52 | ||
@@ -55,6 +56,28 @@ namespace internal { | |||
| 55 | 56 | // Name of the flag (needed for parsing Google Test flag). | |
| 56 | 57 | const char kInternalRunDeathTestFlag[] = "internal_run_death_test"; | |
| 57 | 58 | ||
| 59 | + // A string passed to EXPECT_DEATH (etc.) is caught by one of these overloads | ||
| 60 | + // and interpreted as a regex (rather than an Eq matcher) for legacy | ||
| 61 | + // compatibility. | ||
| 62 | + inline Matcher<const ::std::string&> MakeDeathTestMatcher( | ||
| 63 | + ::testing::internal::RE regex) { | ||
| 64 | + return ContainsRegex(regex.pattern()); | ||
| 65 | + } | ||
| 66 | + inline Matcher<const ::std::string&> MakeDeathTestMatcher(const char* regex) { | ||
| 67 | + return ContainsRegex(regex); | ||
| 68 | + } | ||
| 69 | + inline Matcher<const ::std::string&> MakeDeathTestMatcher( | ||
| 70 | + const ::std::string& regex) { | ||
| 71 | + return ContainsRegex(regex); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + // If a Matcher<const ::std::string&> is passed to EXPECT_DEATH (etc.), it's | ||
| 75 | + // used directly. | ||
| 76 | + inline Matcher<const ::std::string&> MakeDeathTestMatcher( | ||
| 77 | + Matcher<const ::std::string&> matcher) { | ||
| 78 | + return matcher; | ||
| 79 | + } | ||
| 80 | + | ||
| 58 | 81 | #ifdef GTEST_HAS_DEATH_TEST | |
| 59 | 82 | ||
| 60 | 83 | GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ | |
@@ -168,28 +191,6 @@ class DefaultDeathTestFactory : public DeathTestFactory { | |||
| 168 | 191 | // by a signal, or exited normally with a nonzero exit code. | |
| 169 | 192 | GTEST_API_ bool ExitedUnsuccessfully(int exit_status); | |
| 170 | 193 | ||
| 171 | - // A string passed to EXPECT_DEATH (etc.) is caught by one of these overloads | ||
| 172 | - // and interpreted as a regex (rather than an Eq matcher) for legacy | ||
| 173 | - // compatibility. | ||
| 174 | - inline Matcher<const ::std::string&> MakeDeathTestMatcher( | ||
| 175 | - ::testing::internal::RE regex) { | ||
| 176 | - return ContainsRegex(regex.pattern()); | ||
| 177 | - } | ||
| 178 | - inline Matcher<const ::std::string&> MakeDeathTestMatcher(const char* regex) { | ||
| 179 | - return ContainsRegex(regex); | ||
| 180 | - } | ||
| 181 | - inline Matcher<const ::std::string&> MakeDeathTestMatcher( | ||
| 182 | - const ::std::string& regex) { | ||
| 183 | - return ContainsRegex(regex); | ||
| 184 | - } | ||
| 185 | - | ||
| 186 | - // If a Matcher<const ::std::string&> is passed to EXPECT_DEATH (etc.), it's | ||
| 187 | - // used directly. | ||
| 188 | - inline Matcher<const ::std::string&> MakeDeathTestMatcher( | ||
| 189 | - Matcher<const ::std::string&> matcher) { | ||
| 190 | - return matcher; | ||
| 191 | - } | ||
| 192 | - | ||
| 193 | 194 | // Traps C++ exceptions escaping statement and reports them as test | |
| 194 | 195 | // failures. Note that trapping SEH exceptions is not implemented here. | |
| 195 | 196 | #if GTEST_HAS_EXCEPTIONS | |
| Back | FazBrowse Home | New Git URL |
0 commit comments