aboutsummaryrefslogtreecommitdiffstats
path: root/googlemock/test/gmock-nice-strict_test.cc
diff options
context:
space:
mode:
authorTanzinul Islam <t_17_7@hotmail.com>2017-09-06 01:05:24 +0100
committerTanzinul Islam <t_17_7@hotmail.com>2017-09-06 01:05:24 +0100
commit78b1ff074799c776f90a77203fcd7adc98e11736 (patch)
tree21974f2d4f0d4aeaff5a4027df84889a2619ae25 /googlemock/test/gmock-nice-strict_test.cc
parenta838de3348add7530431e8d91c8a66cc646f1888 (diff)
parent857ddeadebe4aa75efcee728651d0947a5a1065a (diff)
downloadgoogletest-78b1ff074799c776f90a77203fcd7adc98e11736.tar.gz
googletest-78b1ff074799c776f90a77203fcd7adc98e11736.tar.bz2
googletest-78b1ff074799c776f90a77203fcd7adc98e11736.zip
Merge branch 'master' into fix_death_test_child_mingw_wer_issue1116
Diffstat (limited to 'googlemock/test/gmock-nice-strict_test.cc')
-rw-r--r--googlemock/test/gmock-nice-strict_test.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/googlemock/test/gmock-nice-strict_test.cc b/googlemock/test/gmock-nice-strict_test.cc
index 5d6ccc4f..0eac6439 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
+// Class without default constructor.
+class NotDefaultConstructible {
+ public:
+ explicit NotDefaultConstructible(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(ReturnNonDefaultConstructible, NotDefaultConstructible());
private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFoo);
@@ -207,6 +214,22 @@ TEST(NiceMockTest, AllowsExpectedCall) {
nice_foo.DoThis();
}
+// Tests that an unexpected call on a nice mock which returns a not-default-constructible
+// type throws an exception and the exception contains the method's name.
+TEST(NiceMockTest, ThrowsExceptionForUnknownReturnTypes) {
+ NiceMock<MockFoo> nice_foo;
+#if GTEST_HAS_EXCEPTIONS
+ try {
+ nice_foo.ReturnNonDefaultConstructible();
+ FAIL();
+ } catch (const std::runtime_error& ex) {
+ EXPECT_THAT(ex.what(), HasSubstr("ReturnNonDefaultConstructible"));
+ }
+#else
+ EXPECT_DEATH_IF_SUPPORTED({ nice_foo.ReturnNonDefaultConstructible(); }, "");
+#endif
+}
+
// Tests that an unexpected call on a nice mock fails.
TEST(NiceMockTest, UnexpectedCallFails) {
NiceMock<MockFoo> nice_foo;