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
026735da
Commit
026735da
authored
Aug 20, 2017
by
Gennadiy Civil
Committed by
GitHub
Aug 20, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Proposing these changes, please review
Slightly better names and cleaner tests. Please review
parent
35737ac7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
12 deletions
+9
-12
gmock-nice-strict_test.cc
googlemock/test/gmock-nice-strict_test.cc
+9
-12
No files found.
googlemock/test/gmock-nice-strict_test.cc
View file @
026735da
...
@@ -62,10 +62,10 @@ using testing::internal::CaptureStdout;
...
@@ -62,10 +62,10 @@ using testing::internal::CaptureStdout;
using
testing
::
internal
::
GetCapturedStdout
;
using
testing
::
internal
::
GetCapturedStdout
;
#endif
#endif
//
Dummy c
lass without default constructor.
//
C
lass without default constructor.
class
Dummy
{
class
NotDefaultConstructible
{
public
:
public
:
Dummy
(
int
)
{}
NotDefaultConstructible
(
int
)
{}
};
};
// Defines some mock classes needed by the tests.
// Defines some mock classes needed by the tests.
...
@@ -85,7 +85,7 @@ class MockFoo : public Foo {
...
@@ -85,7 +85,7 @@ class MockFoo : public Foo {
MOCK_METHOD0
(
DoThis
,
void
());
MOCK_METHOD0
(
DoThis
,
void
());
MOCK_METHOD1
(
DoThat
,
int
(
bool
flag
));
MOCK_METHOD1
(
DoThat
,
int
(
bool
flag
));
MOCK_METHOD0
(
Return
Something
,
Dummy
());
MOCK_METHOD0
(
Return
NonDefaultConstructible
,
NotDefaultConstructible
());
private
:
private
:
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
MockFoo
);
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
MockFoo
);
...
@@ -214,23 +214,20 @@ TEST(NiceMockTest, AllowsExpectedCall) {
...
@@ -214,23 +214,20 @@ TEST(NiceMockTest, AllowsExpectedCall) {
nice_foo
.
DoThis
();
nice_foo
.
DoThis
();
}
}
// Tests that an unexpected call on a nice mock which returns a non-built in
// Tests that an unexpected call on a nice mock which returns a not-default-constructible
// default value throws an exception and the exception contains the name of
// type throws an exception and the exception contains the method's name.
// the method.
TEST
(
NiceMockTest
,
ThrowsExceptionForUnknownReturnTypes
)
{
TEST
(
NiceMockTest
,
ThrowsExceptionForUnknownReturnTypes
)
{
NiceMock
<
MockFoo
>
nice_foo
;
NiceMock
<
MockFoo
>
nice_foo
;
#if GTEST_HAS_EXCEPTIONS
#if GTEST_HAS_EXCEPTIONS
try
{
try
{
nice_foo
.
Return
Something
();
nice_foo
.
Return
NonDefaultConstructible
();
FAIL
();
FAIL
();
}
catch
(
const
std
::
runtime_error
&
ex
)
{
}
catch
(
const
std
::
runtime_error
&
ex
)
{
const
std
::
string
exception_msg
(
ex
.
what
());
const
std
::
string
exception_msg
(
ex
.
what
());
EXPECT_
NE
(
exception_msg
.
find
(
"ReturnSomething"
),
std
::
string
::
npos
);
EXPECT_
THAT
(
ex
.
what
(),
HasSubstr
(
"ReturnNonDefaultConstructible"
)
);
}
}
#else
#else
EXPECT_DEATH_IF_SUPPORTED
({
EXPECT_DEATH_IF_SUPPORTED
({
nice_foo
.
ReturnNonDefaultConstructible
();
},
""
);
nice_foo
.
ReturnSomething
();
},
""
);
#endif
#endif
}
}
...
...
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