diff options
author | Vladimir Goncharov <amatanhead@yandex-team.ru> | 2020-07-03 17:50:06 (GMT) |
---|---|---|
committer | Vladimir Goncharov <amatanhead@yandex-team.ru> | 2020-08-03 20:47:57 (GMT) |
commit | 49d1201a7ec83987deaae161958577deeba1a9ed (patch) | |
tree | e125ed698fce461ac989b54d78b2c9028e4cde81 /googlemock | |
parent | 46734d9a66e858e2b419729b52d6aa21faa614c7 (diff) | |
download | googletest-49d1201a7ec83987deaae161958577deeba1a9ed.zip googletest-49d1201a7ec83987deaae161958577deeba1a9ed.tar.gz googletest-49d1201a7ec83987deaae161958577deeba1a9ed.tar.bz2 |
Add missing documentation piece
Diffstat (limited to 'googlemock')
-rw-r--r-- | googlemock/include/gmock/gmock-matchers.h | 3 | ||||
-rw-r--r-- | googlemock/test/gmock-matchers_test.cc | 20 |
2 files changed, 22 insertions, 1 deletions
diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index cc04564..708c7c8 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -4812,7 +4812,8 @@ class ExceptionMatcherImpl { // // EXPECT_THAT( // []() { throw std::runtime_error("message"); }, -// Throws +// Throws<std::runtime_error>( +// Property(&std::runtime_error::what, HasSubstr("message")))); template <typename Err> PolymorphicMatcher<internal::ExceptionMatcherImpl<Err>> diff --git a/googlemock/test/gmock-matchers_test.cc b/googlemock/test/gmock-matchers_test.cc index dd61a53..0741187 100644 --- a/googlemock/test/gmock-matchers_test.cc +++ b/googlemock/test/gmock-matchers_test.cc @@ -8119,6 +8119,26 @@ TEST(MatcherPMacroTest, WorksOnMoveOnlyType) { #if GTEST_HAS_EXCEPTIONS +// Test that examples from documentation compile +TEST(ThrowsTest, Examples) { + EXPECT_THAT( + []() { throw std::runtime_error("message"); }, + Throws<std::runtime_error>()); + + EXPECT_THAT( + []() { throw std::runtime_error("message"); }, + ThrowsMessage<std::runtime_error>(HasSubstr("message"))); + + 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")))); +} + TEST(ThrowsTest, Describe) { Matcher<void (*)()> matcher = Throws<std::runtime_error>(); std::stringstream ss; |