Add a test for duplicate catch clauses in throw matchers, fix a couple of nitpicks.
This commit is contained in:
parent
49d1201a7e
commit
69c510fb51
@ -4738,7 +4738,6 @@ class ExceptionMatcherImpl {
|
|||||||
ExceptionMatcherImpl(Matcher<const Err&> matcher)
|
ExceptionMatcherImpl(Matcher<const Err&> matcher)
|
||||||
: matcher_(std::move(matcher)) {}
|
: matcher_(std::move(matcher)) {}
|
||||||
|
|
||||||
public:
|
|
||||||
void DescribeTo(::std::ostream* os) const {
|
void DescribeTo(::std::ostream* os) const {
|
||||||
*os << "throws an exception of type " << GetTypeName<Err>();
|
*os << "throws an exception of type " << GetTypeName<Err>();
|
||||||
if (matcher_.GetDescriber() != nullptr) {
|
if (matcher_.GetDescriber() != nullptr) {
|
||||||
@ -4775,7 +4774,7 @@ class ExceptionMatcherImpl {
|
|||||||
*listener << "with description \"" << err.what() << "\"";
|
*listener << "with description \"" << err.what() << "\"";
|
||||||
return false;
|
return false;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
*listener << "throws an exception of some other type";
|
*listener << "throws an exception of an unknown type";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
*listener << "does not throw any exception";
|
*listener << "does not throw any exception";
|
||||||
|
@ -8139,6 +8139,12 @@ TEST(ThrowsTest, Examples) {
|
|||||||
Property(&std::runtime_error::what, HasSubstr("message"))));
|
Property(&std::runtime_error::what, HasSubstr("message"))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(ThrowsTest, DoesNotGenerateDuplicateCatchClauseWarning) {
|
||||||
|
EXPECT_THAT(
|
||||||
|
[]() { throw std::exception(); },
|
||||||
|
Throws<std::exception>());
|
||||||
|
}
|
||||||
|
|
||||||
TEST(ThrowsTest, Describe) {
|
TEST(ThrowsTest, Describe) {
|
||||||
Matcher<void (*)()> matcher = Throws<std::runtime_error>();
|
Matcher<void (*)()> matcher = Throws<std::runtime_error>();
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
Loading…
Reference in New Issue
Block a user