Commit 49d1201a authored by Vladimir Goncharov's avatar Vladimir Goncharov
Browse files

Add missing documentation piece

parent 46734d9a
......@@ -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>>
......
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment