Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
69c510fb
Commit
69c510fb
authored
Jul 07, 2020
by
Vladimir Goncharov
Browse files
Add a test for duplicate catch clauses in throw matchers, fix a couple of nitpicks.
parent
49d1201a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
2 deletions
+7
-2
googlemock/include/gmock/gmock-matchers.h
googlemock/include/gmock/gmock-matchers.h
+1
-2
googlemock/test/gmock-matchers_test.cc
googlemock/test/gmock-matchers_test.cc
+6
-0
No files found.
googlemock/include/gmock/gmock-matchers.h
View file @
69c510fb
...
...
@@ -4738,7 +4738,6 @@ class ExceptionMatcherImpl {
ExceptionMatcherImpl
(
Matcher
<
const
Err
&>
matcher
)
:
matcher_
(
std
::
move
(
matcher
))
{}
public:
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
"throws an exception of type "
<<
GetTypeName
<
Err
>
();
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"
;
...
...
googlemock/test/gmock-matchers_test.cc
View file @
69c510fb
...
...
@@ -8139,6 +8139,12 @@ TEST(ThrowsTest, Examples) {
Property
(
&
std
::
runtime_error
::
what
,
HasSubstr
(
"message"
))));
}
TEST
(
ThrowsTest
,
DoesNotGenerateDuplicateCatchClauseWarning
)
{
EXPECT_THAT
(
[]()
{
throw
std
::
exception
();
},
Throws
<
std
::
exception
>
());
}
TEST
(
ThrowsTest
,
Describe
)
{
Matcher
<
void
(
*
)()
>
matcher
=
Throws
<
std
::
runtime_error
>
();
std
::
stringstream
ss
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment