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
6e372012
Commit
6e372012
authored
Oct 23, 2018
by
Jerry Turcios
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/google/googletest
parents
3468af9b
7b6b3be3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
1 deletion
+52
-1
gmock-spec-builders.h
googlemock/include/gmock/gmock-spec-builders.h
+10
-0
gmock-spec-builders.cc
googlemock/src/gmock-spec-builders.cc
+13
-0
gmock-nice-strict_test.cc
googlemock/test/gmock-nice-strict_test.cc
+28
-0
advanced.md
googletest/docs/advanced.md
+1
-1
No files found.
googlemock/include/gmock/gmock-spec-builders.h
View file @
6e372012
...
...
@@ -399,6 +399,16 @@ class GTEST_API_ Mock {
static
bool
VerifyAndClear
(
void
*
mock_obj
)
GTEST_LOCK_EXCLUDED_
(
internal
::
g_gmock_mutex
);
// Returns whether the mock was created as a naggy mock (default)
static
bool
IsNaggy
(
void
*
mock_obj
)
GTEST_LOCK_EXCLUDED_
(
internal
::
g_gmock_mutex
);
// Returns whether the mock was created as a nice mock
static
bool
IsNice
(
void
*
mock_obj
)
GTEST_LOCK_EXCLUDED_
(
internal
::
g_gmock_mutex
);
// Returns whether the mock was created as a strict mock
static
bool
IsStrict
(
void
*
mock_obj
)
GTEST_LOCK_EXCLUDED_
(
internal
::
g_gmock_mutex
);
private
:
friend
class
internal
::
UntypedFunctionMockerBase
;
...
...
googlemock/src/gmock-spec-builders.cc
View file @
6e372012
...
...
@@ -757,6 +757,19 @@ bool Mock::VerifyAndClearExpectationsLocked(void* mock_obj)
return
expectations_met
;
}
bool
Mock
::
IsNaggy
(
void
*
mock_obj
)
GTEST_LOCK_EXCLUDED_
(
internal
::
g_gmock_mutex
)
{
return
Mock
::
GetReactionOnUninterestingCalls
(
mock_obj
)
==
internal
::
kWarn
;
}
bool
Mock
::
IsNice
(
void
*
mock_obj
)
GTEST_LOCK_EXCLUDED_
(
internal
::
g_gmock_mutex
)
{
return
Mock
::
GetReactionOnUninterestingCalls
(
mock_obj
)
==
internal
::
kAllow
;
}
bool
Mock
::
IsStrict
(
void
*
mock_obj
)
GTEST_LOCK_EXCLUDED_
(
internal
::
g_gmock_mutex
)
{
return
Mock
::
GetReactionOnUninterestingCalls
(
mock_obj
)
==
internal
::
kFail
;
}
// Registers a mock object and a mock method it owns.
void
Mock
::
Register
(
const
void
*
mock_obj
,
internal
::
UntypedFunctionMockerBase
*
mocker
)
...
...
googlemock/test/gmock-nice-strict_test.cc
View file @
6e372012
...
...
@@ -184,6 +184,13 @@ TEST(RawMockTest, InfoForUninterestingCall) {
GMOCK_FLAG
(
verbose
)
=
saved_flag
;
}
TEST
(
RawMockTest
,
IsNaggy_IsNice_IsStrict
)
{
MockFoo
raw_foo
;
EXPECT_TRUE
(
Mock
::
IsNaggy
(
&
raw_foo
));
EXPECT_FALSE
(
Mock
::
IsNice
(
&
raw_foo
));
EXPECT_FALSE
(
Mock
::
IsStrict
(
&
raw_foo
));
}
// Tests that a nice mock generates no warning for uninteresting calls.
TEST
(
NiceMockTest
,
NoWarningForUninterestingCall
)
{
NiceMock
<
MockFoo
>
nice_foo
;
...
...
@@ -309,6 +316,13 @@ TEST(NiceMockTest, AcceptsClassNamedMock) {
}
#endif // !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE
TEST
(
NiceMockTest
,
IsNaggy_IsNice_IsStrict
)
{
NiceMock
<
MockFoo
>
nice_foo
;
EXPECT_FALSE
(
Mock
::
IsNaggy
(
&
nice_foo
));
EXPECT_TRUE
(
Mock
::
IsNice
(
&
nice_foo
));
EXPECT_FALSE
(
Mock
::
IsStrict
(
&
nice_foo
));
}
#if GTEST_HAS_STREAM_REDIRECTION
// Tests that a naggy mock generates warnings for uninteresting calls.
...
...
@@ -417,6 +431,13 @@ TEST(NaggyMockTest, AcceptsClassNamedMock) {
}
#endif // !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE
TEST
(
NaggyMockTest
,
IsNaggy_IsNice_IsStrict
)
{
NaggyMock
<
MockFoo
>
naggy_foo
;
EXPECT_TRUE
(
Mock
::
IsNaggy
(
&
naggy_foo
));
EXPECT_FALSE
(
Mock
::
IsNice
(
&
naggy_foo
));
EXPECT_FALSE
(
Mock
::
IsStrict
(
&
naggy_foo
));
}
// Tests that a strict mock allows expected calls.
TEST
(
StrictMockTest
,
AllowsExpectedCall
)
{
StrictMock
<
MockFoo
>
strict_foo
;
...
...
@@ -506,5 +527,12 @@ TEST(StrictMockTest, AcceptsClassNamedMock) {
}
#endif // !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE
TEST
(
StrictMockTest
,
IsNaggy_IsNice_IsStrict
)
{
StrictMock
<
MockFoo
>
strict_foo
;
EXPECT_FALSE
(
Mock
::
IsNaggy
(
&
strict_foo
));
EXPECT_FALSE
(
Mock
::
IsNice
(
&
strict_foo
));
EXPECT_TRUE
(
Mock
::
IsStrict
(
&
strict_foo
));
}
}
// namespace gmock_nice_strict_test
}
// namespace testing
googletest/docs/advanced.md
View file @
6e372012
...
...
@@ -1487,7 +1487,7 @@ returns the value of `testing::PrintToString(GetParam())`. It does not work for
NOTE: test names must be non-empty, unique, and may only contain ASCII
alphanumeric characters. In particular, they
[
should not contain
underscores](https://g
3doc.corp.google.com/third_party/googletest/googletest/g3doc/faq.md#no-underscores
).
underscores](https://g
ithub.com/google/googletest/blob/master/googletest/docs/faq.md#why-should-test-case-names-and-test-names-not-contain-underscore
).
```
c++
class
MyTestCase
:
public
testing
::
TestWithParam
<
int
>
{};
...
...
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