aboutsummaryrefslogtreecommitdiffstats
path: root/test/gmock_ex_test.cc
diff options
context:
space:
mode:
authorkosak <kosak@google.com>2015-02-14 02:45:40 +0000
committerkosak <kosak@google.com>2015-02-14 02:45:40 +0000
commitd478a1f46d51ac2baa3f3b3896139897f24dc2d1 (patch)
tree0a6fec800c358fc833a48d1f1bb1b4a4cf0c1725 /test/gmock_ex_test.cc
parent02d647925955836d04d90aafb5ae10a092af29bc (diff)
downloadgoogletest-d478a1f46d51ac2baa3f3b3896139897f24dc2d1.tar.gz
googletest-d478a1f46d51ac2baa3f3b3896139897f24dc2d1.tar.bz2
googletest-d478a1f46d51ac2baa3f3b3896139897f24dc2d1.zip
In C++11 and above, makes a mock method whose return type is default
constructible return a default-constructed value by default.
Diffstat (limited to 'test/gmock_ex_test.cc')
-rw-r--r--test/gmock_ex_test.cc15
1 files changed, 9 insertions, 6 deletions
diff --git a/test/gmock_ex_test.cc b/test/gmock_ex_test.cc
index a5a8a421..3afed86a 100644
--- a/test/gmock_ex_test.cc
+++ b/test/gmock_ex_test.cc
@@ -39,14 +39,17 @@ namespace {
using testing::HasSubstr;
using testing::internal::GoogleTestFailureException;
-// A user-defined class.
-class Something {};
+// A type that cannot be default constructed.
+class NonDefaultConstructible {
+ public:
+ explicit NonDefaultConstructible(int /* dummy */) {}
+};
class MockFoo {
public:
// A mock method that returns a user-defined type. Google Mock
// doesn't know what the default value for this type is.
- MOCK_METHOD0(GetSomething, Something());
+ MOCK_METHOD0(GetNonDefaultConstructible, NonDefaultConstructible());
};
#if GTEST_HAS_EXCEPTIONS
@@ -59,9 +62,9 @@ TEST(DefaultValueTest, ThrowsRuntimeErrorWhenNoDefaultValue) {
// nothing about the return type, it doesn't know what to return,
// and has to throw (when exceptions are enabled) or abort
// (otherwise).
- mock.GetSomething();
- FAIL() << "GetSomething()'s return type has no default value, "
- << "so Google Mock should have thrown.";
+ mock.GetNonDefaultConstructible();
+ FAIL() << "GetNonDefaultConstructible()'s return type has no default "
+ << "value, so Google Mock should have thrown.";
} catch (const GoogleTestFailureException& /* unused */) {
FAIL() << "Google Test does not try to catch an exception of type "
<< "GoogleTestFailureException, which is used for reporting "