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
95f18d99
Commit
95f18d99
authored
Aug 18, 2017
by
Maurice Gilden
Browse files
adds test for NiceMock with unknown return value
parent
1183503d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
0 deletions
+15
-0
googlemock/test/gmock-nice-strict_test.cc
googlemock/test/gmock-nice-strict_test.cc
+15
-0
No files found.
googlemock/test/gmock-nice-strict_test.cc
View file @
95f18d99
...
...
@@ -79,6 +79,7 @@ class MockFoo : public Foo {
MOCK_METHOD0
(
DoThis
,
void
());
MOCK_METHOD1
(
DoThat
,
int
(
bool
flag
));
MOCK_METHOD0
(
ReturnSomething
,
Mock
());
private:
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
MockFoo
);
...
...
@@ -207,6 +208,20 @@ TEST(NiceMockTest, AllowsExpectedCall) {
nice_foo
.
DoThis
();
}
// Tests that an unexpected call on a nice mock which returns a non-built in
// default value throws an exception and the exception contains the name of
// the method.
TEST
(
NiceMockTest
,
ThrowsExceptionForUnknownReturnTypes
)
{
NiceMock
<
MockFoo
>
nice_foo
;
try
{
nice_foo
.
ReturnSomething
();
FAIL
();
}
catch
(
const
std
::
runtime_error
&
ex
)
{
const
std
::
string
exception_msg
(
ex
.
what
());
EXPECT_NE
(
exception_msg
.
find
(
"ReturnSomething"
),
std
::
string
::
npos
);
}
}
// 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