Handling invalid flag values
This commit is contained in:
parent
6e1970e237
commit
a2803bc37d
@ -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(
|
|||||||
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::intToCallReaction(GMOCK_FLAG(default_mock_behavior)) :
|
||||||
g_uninteresting_call_reaction[mock_obj];
|
g_uninteresting_call_reaction[mock_obj];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user