Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
a2803bc3
Commit
a2803bc3
authored
Aug 16, 2017
by
Alyssa Wilk
Browse files
Handling invalid flag values
parent
6e1970e2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
1 deletion
+28
-1
googlemock/src/gmock-spec-builders.cc
googlemock/src/gmock-spec-builders.cc
+8
-1
googlemock/test/gmock-spec-builders_test.cc
googlemock/test/gmock-spec-builders_test.cc
+20
-0
No files found.
googlemock/src/gmock-spec-builders.cc
View file @
a2803bc3
...
@@ -508,6 +508,13 @@ bool UntypedFunctionMockerBase::VerifyAndClearExpectationsLocked()
...
@@ -508,6 +508,13 @@ bool UntypedFunctionMockerBase::VerifyAndClearExpectationsLocked()
return
expectations_met
;
return
expectations_met
;
}
}
CallReaction
intToCallReaction
(
int
mock_behavior
)
{
if
(
mock_behavior
>=
kAllow
&&
mock_behavior
<=
kFail
)
{
return
static_cast
<
internal
::
CallReaction
>
(
mock_behavior
);
}
return
kWarn
;
}
}
// namespace internal
}
// namespace internal
// Class Mock.
// Class Mock.
...
@@ -648,7 +655,7 @@ internal::CallReaction Mock::GetReactionOnUninterestingCalls(
...
@@ -648,7 +655,7 @@ internal::CallReaction Mock::GetReactionOnUninterestingCalls(
GTEST_LOCK_EXCLUDED_
(
internal
::
g_gmock_mutex
)
{
GTEST_LOCK_EXCLUDED_
(
internal
::
g_gmock_mutex
)
{
internal
::
MutexLock
l
(
&
internal
::
g_gmock_mutex
);
internal
::
MutexLock
l
(
&
internal
::
g_gmock_mutex
);
return
(
g_uninteresting_call_reaction
.
count
(
mock_obj
)
==
0
)
?
return
(
g_uninteresting_call_reaction
.
count
(
mock_obj
)
==
0
)
?
static_cast
<
internal
::
CallReaction
>
(
GMOCK_FLAG
(
default_mock_behavior
))
:
internal
::
intTo
CallReaction
(
GMOCK_FLAG
(
default_mock_behavior
))
:
g_uninteresting_call_reaction
[
mock_obj
];
g_uninteresting_call_reaction
[
mock_obj
];
}
}
...
...
googlemock/test/gmock-spec-builders_test.cc
View file @
a2803bc3
...
@@ -722,6 +722,26 @@ TEST(ExpectCallSyntaxTest, WarningIsErrorWithFlag) {
...
@@ -722,6 +722,26 @@ TEST(ExpectCallSyntaxTest, WarningIsErrorWithFlag) {
a
.
DoA
(
0
);
a
.
DoA
(
0
);
},
"Uninteresting mock function call"
);
},
"Uninteresting mock function call"
);
// Out of bounds values are converted to kWarn
testing
::
GMOCK_FLAG
(
default_mock_behavior
)
=
-
1
;
CaptureStdout
();
{
MockA
a
;
a
.
DoA
(
0
);
}
warning_output
=
GetCapturedStdout
();
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"GMOCK WARNING"
,
warning_output
);
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"Uninteresting mock function call"
,
warning_output
);
testing
::
GMOCK_FLAG
(
default_mock_behavior
)
=
3
;
CaptureStdout
();
{
MockA
a
;
a
.
DoA
(
0
);
}
warning_output
=
GetCapturedStdout
();
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"GMOCK WARNING"
,
warning_output
);
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"Uninteresting mock function call"
,
warning_output
);
testing
::
GMOCK_FLAG
(
default_mock_behavior
)
=
original_behavior
;
testing
::
GMOCK_FLAG
(
default_mock_behavior
)
=
original_behavior
;
}
}
...
...
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