aboutsummaryrefslogtreecommitdiffstats
path: root/googlemock
diff options
context:
space:
mode:
Diffstat (limited to 'googlemock')
-rw-r--r--googlemock/src/gmock-spec-builders.cc2
-rw-r--r--googlemock/test/gmock-nice-strict_test.cc27
2 files changed, 28 insertions, 1 deletions
diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc
index 2fa1ee4b..f761f97e 100644
--- a/googlemock/src/gmock-spec-builders.cc
+++ b/googlemock/src/gmock-spec-builders.cc
@@ -364,7 +364,7 @@ UntypedFunctionMockerBase::UntypedInvokeWith(const void* const untyped_args)
if (!need_to_report_uninteresting_call) {
// Perform the action without printing the call information.
- return this->UntypedPerformDefaultAction(untyped_args, "");
+ return this->UntypedPerformDefaultAction(untyped_args, "Function call: " + std::string(Name()));
}
// Warns about the uninteresting call.
diff --git a/googlemock/test/gmock-nice-strict_test.cc b/googlemock/test/gmock-nice-strict_test.cc
index 5d6ccc4f..a8032e24 100644
--- a/googlemock/test/gmock-nice-strict_test.cc
+++ b/googlemock/test/gmock-nice-strict_test.cc
@@ -62,6 +62,12 @@ using testing::internal::CaptureStdout;
using testing::internal::GetCapturedStdout;
#endif
+// Dummy class without default constructor.
+class Dummy {
+ public:
+ Dummy(int) {}
+};
+
// Defines some mock classes needed by the tests.
class Foo {
@@ -79,6 +85,7 @@ class MockFoo : public Foo {
MOCK_METHOD0(DoThis, void());
MOCK_METHOD1(DoThat, int(bool flag));
+ MOCK_METHOD0(ReturnSomething, Dummy());
private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFoo);
@@ -207,6 +214,26 @@ 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;
+#if GTEST_HAS_EXCEPTIONS
+ 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);
+ }
+#else
+ EXPECT_DEATH_IF_SUPPORTED({
+ nice_foo.ReturnSomething();
+ }, "");
+#endif
+}
+
// Tests that an unexpected call on a nice mock fails.
TEST(NiceMockTest, UnexpectedCallFails) {
NiceMock<MockFoo> nice_foo;