aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaurice Gilden <Maurice.Gilden@teamviewer.com>2017-08-18 11:21:28 +0200
committerMaurice Gilden <Maurice.Gilden@teamviewer.com>2017-08-18 11:21:28 +0200
commit95f18d99383c27bf645e8dc4f5dcaa188f6bafe3 (patch)
treed839452a05e8720b9b6dcd16b8a46e07673d98c2
parent1183503d11f9f694014e8132f011143687a67aa4 (diff)
downloadgoogletest-95f18d99383c27bf645e8dc4f5dcaa188f6bafe3.tar.gz
googletest-95f18d99383c27bf645e8dc4f5dcaa188f6bafe3.tar.bz2
googletest-95f18d99383c27bf645e8dc4f5dcaa188f6bafe3.zip
adds test for NiceMock with unknown return value
-rw-r--r--googlemock/test/gmock-nice-strict_test.cc15
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 5d6ccc4f..5e6d53be 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;