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
20eaf6e3
Commit
20eaf6e3
authored
Oct 23, 2018
by
Gennadiy Civil
Browse files
Merge pull request #1911 from BrukerJWD:isnice
PiperOrigin-RevId: 218384341
parents
a743780a
0cefda77
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
3 deletions
+54
-3
googlemock/docs/DesignDoc.md
googlemock/docs/DesignDoc.md
+0
-1
googlemock/include/gmock/gmock-spec-builders.h
googlemock/include/gmock/gmock-spec-builders.h
+10
-0
googlemock/src/gmock-spec-builders.cc
googlemock/src/gmock-spec-builders.cc
+13
-0
googlemock/test/gmock-nice-strict_test.cc
googlemock/test/gmock-nice-strict_test.cc
+28
-0
googletest/docs/advanced.md
googletest/docs/advanced.md
+3
-2
No files found.
googlemock/docs/DesignDoc.md
View file @
20eaf6e3
...
@@ -198,7 +198,6 @@ Google Test (the name is chosen to match `static_assert` in C++0x).
...
@@ -198,7 +198,6 @@ Google Test (the name is chosen to match `static_assert` in C++0x).
If you are writing a function that returns an
`ACTION`
object, you'll
If you are writing a function that returns an
`ACTION`
object, you'll
need to know its type. The type depends on the macro used to define
need to know its type. The type depends on the macro used to define
the action and the parameter types. The rule is relatively simple:
the action and the parameter types. The rule is relatively simple:
|
**Given Definition**
|
**Expression**
|
**Has Type**
|
|
**Given Definition**
|
**Expression**
|
**Has Type**
|
|:-------------------------|:-----------------------------|:-------------------------|
|:-------------------------|:-----------------------------|:-------------------------|
|
`ACTION(Foo)`
|
`Foo()`
|
`FooAction`
|
|
`ACTION(Foo)`
|
`Foo()`
|
`FooAction`
|
...
...
googlemock/include/gmock/gmock-spec-builders.h
View file @
20eaf6e3
...
@@ -399,6 +399,16 @@ class GTEST_API_ Mock {
...
@@ -399,6 +399,16 @@ class GTEST_API_ Mock {
static
bool
VerifyAndClear
(
void
*
mock_obj
)
static
bool
VerifyAndClear
(
void
*
mock_obj
)
GTEST_LOCK_EXCLUDED_
(
internal
::
g_gmock_mutex
);
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:
private:
friend
class
internal
::
UntypedFunctionMockerBase
;
friend
class
internal
::
UntypedFunctionMockerBase
;
...
...
googlemock/src/gmock-spec-builders.cc
View file @
20eaf6e3
...
@@ -757,6 +757,19 @@ bool Mock::VerifyAndClearExpectationsLocked(void* mock_obj)
...
@@ -757,6 +757,19 @@ bool Mock::VerifyAndClearExpectationsLocked(void* mock_obj)
return
expectations_met
;
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.
// Registers a mock object and a mock method it owns.
void
Mock
::
Register
(
const
void
*
mock_obj
,
void
Mock
::
Register
(
const
void
*
mock_obj
,
internal
::
UntypedFunctionMockerBase
*
mocker
)
internal
::
UntypedFunctionMockerBase
*
mocker
)
...
...
googlemock/test/gmock-nice-strict_test.cc
View file @
20eaf6e3
...
@@ -184,6 +184,13 @@ TEST(RawMockTest, InfoForUninterestingCall) {
...
@@ -184,6 +184,13 @@ TEST(RawMockTest, InfoForUninterestingCall) {
GMOCK_FLAG
(
verbose
)
=
saved_flag
;
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.
// Tests that a nice mock generates no warning for uninteresting calls.
TEST
(
NiceMockTest
,
NoWarningForUninterestingCall
)
{
TEST
(
NiceMockTest
,
NoWarningForUninterestingCall
)
{
NiceMock
<
MockFoo
>
nice_foo
;
NiceMock
<
MockFoo
>
nice_foo
;
...
@@ -309,6 +316,13 @@ TEST(NiceMockTest, AcceptsClassNamedMock) {
...
@@ -309,6 +316,13 @@ TEST(NiceMockTest, AcceptsClassNamedMock) {
}
}
#endif // !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE
#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
#if GTEST_HAS_STREAM_REDIRECTION
// Tests that a naggy mock generates warnings for uninteresting calls.
// Tests that a naggy mock generates warnings for uninteresting calls.
...
@@ -417,6 +431,13 @@ TEST(NaggyMockTest, AcceptsClassNamedMock) {
...
@@ -417,6 +431,13 @@ TEST(NaggyMockTest, AcceptsClassNamedMock) {
}
}
#endif // !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE
#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.
// Tests that a strict mock allows expected calls.
TEST
(
StrictMockTest
,
AllowsExpectedCall
)
{
TEST
(
StrictMockTest
,
AllowsExpectedCall
)
{
StrictMock
<
MockFoo
>
strict_foo
;
StrictMock
<
MockFoo
>
strict_foo
;
...
@@ -506,5 +527,12 @@ TEST(StrictMockTest, AcceptsClassNamedMock) {
...
@@ -506,5 +527,12 @@ TEST(StrictMockTest, AcceptsClassNamedMock) {
}
}
#endif // !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE
#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 gmock_nice_strict_test
}
// namespace testing
}
// namespace testing
googletest/docs/advanced.md
View file @
20eaf6e3
...
@@ -1487,7 +1487,7 @@ returns the value of `testing::PrintToString(GetParam())`. It does not work for
...
@@ -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
NOTE: test names must be non-empty, unique, and may only contain ASCII
alphanumeric characters. In particular, they
[
should not contain
alphanumeric characters. In particular, they
[
should not contain
underscores
](
https://g
ithub.com/google/googletest/blob/master
/googletest/doc
s
/faq.md#
why-should-test-case-names-and-test-names-not-contai
n-underscore
)
.
underscores
](
https://g
3doc.corp.google.com/third_party/googletest
/googletest/
g3
doc/faq.md#n
o
-underscore
s
)
.
```
c++
```
c++
class
MyTestCase
:
public
testing
::
TestWithParam
<
int
>
{};
class
MyTestCase
:
public
testing
::
TestWithParam
<
int
>
{};
...
@@ -2204,7 +2204,8 @@ environment variable to `0`.
...
@@ -2204,7 +2204,8 @@ environment variable to `0`.
googletest can emit a detailed XML report to a file in addition to its normal
googletest can emit a detailed XML report to a file in addition to its normal
textual output. The report contains the duration of each test, and thus can help
textual output. The report contains the duration of each test, and thus can help
you identify slow tests.
you identify slow tests. The report is also used by the http://unittest
dashboard to show per-test-method error messages.
To generate the XML report, set the
`GTEST_OUTPUT`
environment variable or the
To generate the XML report, set the
`GTEST_OUTPUT`
environment variable or the
`--gtest_output`
flag to the string
`"xml:path_to_output_file"`
, which will
`--gtest_output`
flag to the string
`"xml:path_to_output_file"`
, which will
...
...
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