Makes googlemock throw a runtime_error instead of abort when a mock

method with no default value is invoked (if exceptions are enabled).
This commit is contained in:
zhanyong.wan
2013-02-28 22:58:51 +00:00
parent cf40604cf0
commit edd4ab4945
4 changed files with 283 additions and 107 deletions

View File

@@ -634,15 +634,19 @@ TEST(DoDefaultTest, ReturnsBuiltInDefaultValueByDefault) {
EXPECT_EQ(0, mock.IntFunc(true));
}
// Tests that DoDefault() aborts the process when there is no built-in
// default value for the return type.
// Tests that DoDefault() throws (when exceptions are enabled) or aborts
// the process when there is no built-in default value for the return type.
TEST(DoDefaultDeathTest, DiesForUnknowType) {
MockClass mock;
EXPECT_CALL(mock, Foo())
.WillRepeatedly(DoDefault());
#if GTEST_HAS_EXCEPTIONS
EXPECT_ANY_THROW(mock.Foo());
#else
EXPECT_DEATH_IF_SUPPORTED({
mock.Foo();
}, "");
#endif
}
// Tests that using DoDefault() inside a composite action leads to a