diff options
Diffstat (limited to 'googlemock/test/gmock-more-actions_test.cc')
-rw-r--r-- | googlemock/test/gmock-more-actions_test.cc | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/googlemock/test/gmock-more-actions_test.cc b/googlemock/test/gmock-more-actions_test.cc index 97ec5cf..d6a078b 100644 --- a/googlemock/test/gmock-more-actions_test.cc +++ b/googlemock/test/gmock-more-actions_test.cc @@ -38,7 +38,9 @@ #include <memory> #include <sstream> #include <string> + #include "gmock/gmock.h" +#include "gtest/gtest-spi.h" #include "gtest/gtest.h" namespace testing { @@ -604,6 +606,33 @@ TEST(ThrowActionTest, ThrowsGivenExceptionInNullaryFunction) { EXPECT_THROW(a.Perform(std::make_tuple()), MyException); } +class Object { + public: + virtual ~Object() {} + virtual void Func() {} +}; + +class MockObject : public Object { + public: + ~MockObject() override {} + MOCK_METHOD(void, Func, (), (override)); +}; + +TEST(ThrowActionTest, Times0) { + EXPECT_NONFATAL_FAILURE( + [] { + try { + MockObject m; + ON_CALL(m, Func()).WillByDefault([] { throw "something"; }); + EXPECT_CALL(m, Func()).Times(0); + m.Func(); + } catch (...) { + // Exception is caught but Times(0) still triggers a failure. + } + }(), + ""); +} + #endif // GTEST_HAS_EXCEPTIONS // Tests that SetArrayArgument<N>(first, last) sets the elements of the array |