diff options
author | zhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386> | 2010-01-14 05:36:32 +0000 |
---|---|---|
committer | zhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386> | 2010-01-14 05:36:32 +0000 |
commit | d14aaed74b2a8a1222d60d8fa3afcfc93a21c321 (patch) | |
tree | cf118668b44f1b3914c22003d763bb58504a37eb /test/gmock-spec-builders_test.cc | |
parent | 6953a725fc2151eff18078f8315d92811cd4d90e (diff) | |
download | googletest-d14aaed74b2a8a1222d60d8fa3afcfc93a21c321.tar.gz googletest-d14aaed74b2a8a1222d60d8fa3afcfc93a21c321.tar.bz2 googletest-d14aaed74b2a8a1222d60d8fa3afcfc93a21c321.zip |
Enables regex matchers on all platforms.
Diffstat (limited to 'test/gmock-spec-builders_test.cc')
-rw-r--r-- | test/gmock-spec-builders_test.cc | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/test/gmock-spec-builders_test.cc b/test/gmock-spec-builders_test.cc index c1e77381..3a7b4189 100644 --- a/test/gmock-spec-builders_test.cc +++ b/test/gmock-spec-builders_test.cc @@ -68,6 +68,7 @@ using testing::AtMost; using testing::Between; using testing::Cardinality; using testing::CardinalityInterface; +using testing::ContainsRegex; using testing::Const; using testing::DoAll; using testing::DoDefault; @@ -978,8 +979,6 @@ TEST(UnexpectedCallTest, UnmatchedArguments) { b.DoB(1); } -#ifdef GMOCK_HAS_REGEX - // Tests that Google Mock explains that an expectation with // unsatisfied pre-requisites doesn't match the call. TEST(UnexpectedCallTest, UnsatisifiedPrerequisites) { @@ -1010,31 +1009,33 @@ TEST(UnexpectedCallTest, UnsatisifiedPrerequisites) { // Verifies that the failure message contains the two unsatisfied // pre-requisites but not the satisfied one. - const char* const pattern = -#if GMOCK_USES_PCRE +#if GTEST_USES_PCRE + EXPECT_THAT(r.message(), ContainsRegex( // PCRE has trouble using (.|\n) to match any character, but // supports the (?s) prefix for using . to match any character. "(?s)the following immediate pre-requisites are not satisfied:\n" ".*: pre-requisite #0\n" - ".*: pre-requisite #1"; -#else + ".*: pre-requisite #1")); +#elif GTEST_USES_POSIX_RE + EXPECT_THAT(r.message(), ContainsRegex( // POSIX RE doesn't understand the (?s) prefix, but has no trouble // with (.|\n). "the following immediate pre-requisites are not satisfied:\n" "(.|\n)*: pre-requisite #0\n" - "(.|\n)*: pre-requisite #1"; -#endif // GMOCK_USES_PCRE + "(.|\n)*: pre-requisite #1")); +#else + // We can only use Google Test's own simple regex. + EXPECT_THAT(r.message(), ContainsRegex( + "the following immediate pre-requisites are not satisfied:")); + EXPECT_THAT(r.message(), ContainsRegex(": pre-requisite #0")); + EXPECT_THAT(r.message(), ContainsRegex(": pre-requisite #1")); +#endif // GTEST_USES_PCRE - EXPECT_TRUE( - ::testing::internal::RE::PartialMatch(r.message(), pattern)) - << " where the message is " << r.message(); b.DoB(1); b.DoB(3); b.DoB(4); } -#endif // GMOCK_HAS_REGEX - TEST(UndefinedReturnValueTest, ReturnValueIsMandatory) { MockA a; // TODO(wan@google.com): We should really verify the output message, |