Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
googletest
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
googletest
Commits
69c510fb
Commit
69c510fb
authored
Jul 07, 2020
by
Vladimir Goncharov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a test for duplicate catch clauses in throw matchers, fix a couple of nitpicks.
parent
49d1201a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
2 deletions
+7
-2
gmock-matchers.h
googlemock/include/gmock/gmock-matchers.h
+1
-2
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 {
...
@@ -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 {
...
@@ -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"
;
...
...
googlemock/test/gmock-matchers_test.cc
View file @
69c510fb
...
@@ -8139,6 +8139,12 @@ TEST(ThrowsTest, Examples) {
...
@@ -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
;
...
...
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