Add missing documentation piece

This commit is contained in:
Vladimir Goncharov 2020-07-03 20:50:06 +03:00
parent 46734d9a66
commit 49d1201a7e
2 changed files with 22 additions and 1 deletions

View File

@ -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>>

View File

@ -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;