4646
4747#include " gtest/gtest-matchers.h"
4848#include " gtest/internal/gtest-internal.h"
49+ #include " gtest/internal/gtest-port.h"
4950
5051GTEST_DECLARE_string_ (internal_run_death_test);
5152
@@ -55,6 +56,28 @@ namespace internal {
5556// Name of the flag (needed for parsing Google Test flag).
5657const char kInternalRunDeathTestFlag [] = " internal_run_death_test" ;
5758
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+
5881#ifdef GTEST_HAS_DEATH_TEST
5982
6083GTEST_DISABLE_MSC_WARNINGS_PUSH_ (4251 \
@@ -168,28 +191,6 @@ class DefaultDeathTestFactory : public DeathTestFactory {
168191// by a signal, or exited normally with a nonzero exit code.
169192GTEST_API_ bool ExitedUnsuccessfully (int exit_status);
170193
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-
193194// Traps C++ exceptions escaping statement and reports them as test
194195// failures. Note that trapping SEH exceptions is not implemented here.
195196#if GTEST_HAS_EXCEPTIONS
0 commit comments