diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index 708c7c87..36625209 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -4738,7 +4738,6 @@ class ExceptionMatcherImpl { ExceptionMatcherImpl(Matcher matcher) : matcher_(std::move(matcher)) {} - public: void DescribeTo(::std::ostream* os) const { *os << "throws an exception of type " << GetTypeName(); if (matcher_.GetDescriber() != nullptr) { @@ -4775,7 +4774,7 @@ class ExceptionMatcherImpl { *listener << "with description \"" << err.what() << "\""; return false; } catch (...) { - *listener << "throws an exception of some other type"; + *listener << "throws an exception of an unknown type"; return false; } *listener << "does not throw any exception"; diff --git a/googlemock/test/gmock-matchers_test.cc b/googlemock/test/gmock-matchers_test.cc index 07411873..cd89d81e 100644 --- a/googlemock/test/gmock-matchers_test.cc +++ b/googlemock/test/gmock-matchers_test.cc @@ -8139,6 +8139,12 @@ TEST(ThrowsTest, Examples) { Property(&std::runtime_error::what, HasSubstr("message")))); } +TEST(ThrowsTest, DoesNotGenerateDuplicateCatchClauseWarning) { + EXPECT_THAT( + []() { throw std::exception(); }, + Throws()); +} + TEST(ThrowsTest, Describe) { Matcher matcher = Throws(); std::stringstream ss;