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
675686a1
Commit
675686a1
authored
Aug 21, 2017
by
Gennadiy Civil
Committed by
GitHub
Aug 21, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1206 from ShadowIce/methodname-in-exception
Add function name to exception if there's no default action
parents
780bae0f
1ee80796
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
1 deletion
+24
-1
gmock-spec-builders.cc
googlemock/src/gmock-spec-builders.cc
+1
-1
gmock-nice-strict_test.cc
googlemock/test/gmock-nice-strict_test.cc
+23
-0
No files found.
googlemock/src/gmock-spec-builders.cc
View file @
675686a1
...
...
@@ -364,7 +364,7 @@ UntypedFunctionMockerBase::UntypedInvokeWith(const void* const untyped_args)
if
(
!
need_to_report_uninteresting_call
)
{
// Perform the action without printing the call information.
return
this
->
UntypedPerformDefaultAction
(
untyped_args
,
"
"
);
return
this
->
UntypedPerformDefaultAction
(
untyped_args
,
"
Function call: "
+
std
::
string
(
Name
())
);
}
// Warns about the uninteresting call.
...
...
googlemock/test/gmock-nice-strict_test.cc
View file @
675686a1
...
...
@@ -62,6 +62,12 @@ using testing::internal::CaptureStdout;
using
testing
::
internal
::
GetCapturedStdout
;
#endif
// Class without default constructor.
class
NotDefaultConstructible
{
public
:
explicit
NotDefaultConstructible
(
int
)
{}
};
// Defines some mock classes needed by the tests.
class
Foo
{
...
...
@@ -79,6 +85,7 @@ class MockFoo : public Foo {
MOCK_METHOD0
(
DoThis
,
void
());
MOCK_METHOD1
(
DoThat
,
int
(
bool
flag
));
MOCK_METHOD0
(
ReturnNonDefaultConstructible
,
NotDefaultConstructible
());
private
:
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
MockFoo
);
...
...
@@ -207,6 +214,22 @@ TEST(NiceMockTest, AllowsExpectedCall) {
nice_foo
.
DoThis
();
}
// Tests that an unexpected call on a nice mock which returns a not-default-constructible
// type throws an exception and the exception contains the method's name.
TEST
(
NiceMockTest
,
ThrowsExceptionForUnknownReturnTypes
)
{
NiceMock
<
MockFoo
>
nice_foo
;
#if GTEST_HAS_EXCEPTIONS
try
{
nice_foo
.
ReturnNonDefaultConstructible
();
FAIL
();
}
catch
(
const
std
::
runtime_error
&
ex
)
{
EXPECT_THAT
(
ex
.
what
(),
HasSubstr
(
"ReturnNonDefaultConstructible"
));
}
#else
EXPECT_DEATH_IF_SUPPORTED
({
nice_foo
.
ReturnNonDefaultConstructible
();
},
""
);
#endif
}
// Tests that an unexpected call on a nice mock fails.
TEST
(
NiceMockTest
,
UnexpectedCallFails
)
{
NiceMock
<
MockFoo
>
nice_foo
;
...
...
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