diff options
author | Maurice Gilden <Maurice.Gilden@teamviewer.com> | 2017-08-18 09:21:28 (GMT) |
---|---|---|
committer | Maurice Gilden <Maurice.Gilden@teamviewer.com> | 2017-08-18 09:21:28 (GMT) |
commit | 95f18d99383c27bf645e8dc4f5dcaa188f6bafe3 (patch) | |
tree | d839452a05e8720b9b6dcd16b8a46e07673d98c2 /googlemock | |
parent | 1183503d11f9f694014e8132f011143687a67aa4 (diff) | |
download | googletest-95f18d99383c27bf645e8dc4f5dcaa188f6bafe3.zip googletest-95f18d99383c27bf645e8dc4f5dcaa188f6bafe3.tar.gz googletest-95f18d99383c27bf645e8dc4f5dcaa188f6bafe3.tar.bz2 |
adds test for NiceMock with unknown return value
Diffstat (limited to 'googlemock')
-rw-r--r-- | googlemock/test/gmock-nice-strict_test.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/googlemock/test/gmock-nice-strict_test.cc b/googlemock/test/gmock-nice-strict_test.cc index 5d6ccc4..5e6d53b 100644 --- a/googlemock/test/gmock-nice-strict_test.cc +++ b/googlemock/test/gmock-nice-strict_test.cc @@ -79,6 +79,7 @@ class MockFoo : public Foo { MOCK_METHOD0(DoThis, void()); MOCK_METHOD1(DoThat, int(bool flag)); + MOCK_METHOD0(ReturnSomething, Mock()); private: GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFoo); @@ -207,6 +208,20 @@ TEST(NiceMockTest, AllowsExpectedCall) { nice_foo.DoThis(); } +// Tests that an unexpected call on a nice mock which returns a non-built in +// default value throws an exception and the exception contains the name of +// the method. +TEST(NiceMockTest, ThrowsExceptionForUnknownReturnTypes) { + NiceMock<MockFoo> nice_foo; + try { + nice_foo.ReturnSomething(); + FAIL(); + } catch (const std::runtime_error& ex) { + const std::string exception_msg(ex.what()); + EXPECT_NE(exception_msg.find("ReturnSomething"), std::string::npos); + } +} + // Tests that an unexpected call on a nice mock fails. TEST(NiceMockTest, UnexpectedCallFails) { NiceMock<MockFoo> nice_foo; |