diff options
author | Vladimir Goncharov <amatanhead@yandex-team.ru> | 2020-08-03 20:44:27 (GMT) |
---|---|---|
committer | Vladimir Goncharov <amatanhead@yandex-team.ru> | 2020-08-03 20:47:57 (GMT) |
commit | 7f1c8bb44718d68cb96a3eea033856b8c0ad9a3d (patch) | |
tree | 6d9879911efc7ecf52e0e35556225fc715763514 /googlemock/include/gmock/gmock-matchers.h | |
parent | a899cecb11d35a41393456be3bc5ed8a8c815da8 (diff) | |
download | googletest-7f1c8bb44718d68cb96a3eea033856b8c0ad9a3d.zip googletest-7f1c8bb44718d68cb96a3eea033856b8c0ad9a3d.tar.gz googletest-7f1c8bb44718d68cb96a3eea033856b8c0ad9a3d.tar.bz2 |
Remove ThrowsMessageHasSubstr and fix some nits after reviewrefs/pull/2904/head
Diffstat (limited to 'googlemock/include/gmock/gmock-matchers.h')
-rw-r--r-- | googlemock/include/gmock/gmock-matchers.h | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index 969d920..59ef2f3 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -4774,15 +4774,15 @@ class ExceptionMatcherImpl { ExceptionMatcherImpl(Matcher<const Err&> matcher) : matcher_(std::move(matcher)) {} - void DescribeTo(::std::ostream* os) const { - *os << "throws an exception of type " << GetTypeName<Err>(); + void DescribeTo(std::ostream* os) const { + *os << "throws an exception which is a " << GetTypeName<Err>(); if (matcher_.GetDescriber() != nullptr) { *os << " which "; matcher_.DescribeTo(os); } } - void DescribeNegationTo(::std::ostream* os) const { + void DescribeNegationTo(std::ostream* os) const { *os << "not ("; DescribeTo(os); *os << ")"; @@ -4793,7 +4793,7 @@ class ExceptionMatcherImpl { try { (void)(std::forward<T>(x)()); } catch (const Err& err) { - *listener << "throws an exception of type " << GetTypeName<Err>(); + *listener << "throws an exception which is a " << GetTypeName<Err>(); if (matcher_.GetDescriber() != nullptr) { *listener << " "; return matcher_.MatchAndExplain(err, listener); @@ -4826,7 +4826,6 @@ class ExceptionMatcherImpl { // Throws() // Throws(exceptionMatcher) // ThrowsMessage(messageMatcher) -// ThrowsMessageHasSubstr(message) // // This matcher accepts a callable and verifies that when invoked, it throws // an exception with the given type and properties. @@ -4843,10 +4842,6 @@ class ExceptionMatcherImpl { // // EXPECT_THAT( // []() { throw std::runtime_error("message"); }, -// ThrowsMessageHasSubstr<std::runtime_error>("message")); -// -// EXPECT_THAT( -// []() { throw std::runtime_error("message"); }, // Throws<std::runtime_error>( // Property(&std::runtime_error::what, HasSubstr("message")))); @@ -4882,16 +4877,6 @@ ThrowsMessage(const MessageMatcher& messageMatcher) { Property("what", &std::exception::what, MatcherCast<std::string>(messageMatcher))}); } -template <typename Err, typename Message = std::string> -PolymorphicMatcher<internal::ExceptionMatcherImpl<Err>> -ThrowsMessageHasSubstr(const internal::StringLike<Message>& message) { - static_assert( - std::is_base_of<std::exception, Err>::value, - "expected an std::exception-derived class"); - return MakePolymorphicMatcher( - internal::ExceptionMatcherImpl<Err>{ - Property("what", &std::exception::what, HasSubstr(message))}); -} #endif // GTEST_HAS_EXCEPTIONS |