aboutsummaryrefslogtreecommitdiffstats
path: root/test/gmock-generated-function-mockers_test.cc
diff options
context:
space:
mode:
authorkosak <kosak@google.com>2015-07-24 20:05:26 +0000
committerkosak <kosak@google.com>2015-07-24 20:05:26 +0000
commita6e32f0a2c681c2fa0a022da24b0a4be903cf13b (patch)
tree098f954f33214584c47708af0ad665aec74da20b /test/gmock-generated-function-mockers_test.cc
parentf6df4c6baf244bc35a385b49ffb32be405f44e0e (diff)
downloadgoogletest-a6e32f0a2c681c2fa0a022da24b0a4be903cf13b.tar.gz
googletest-a6e32f0a2c681c2fa0a022da24b0a4be903cf13b.tar.bz2
googletest-a6e32f0a2c681c2fa0a022da24b0a4be903cf13b.zip
Explicitly specify return value for lambda in AsStdFunction() to ensure it
works properly where return type is a reference.
Diffstat (limited to 'test/gmock-generated-function-mockers_test.cc')
-rw-r--r--test/gmock-generated-function-mockers_test.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/gmock-generated-function-mockers_test.cc b/test/gmock-generated-function-mockers_test.cc
index 18f19d8c..a86a6135 100644
--- a/test/gmock-generated-function-mockers_test.cc
+++ b/test/gmock-generated-function-mockers_test.cc
@@ -606,6 +606,16 @@ TEST(MockFunctionTest, AsStdFunction) {
EXPECT_EQ(-1, call(foo.AsStdFunction(), 1));
EXPECT_EQ(-2, call(foo.AsStdFunction(), 2));
}
+
+TEST(MockFunctionTest, AsStdFunctionReturnsReference) {
+ MockFunction<int&()> foo;
+ int value = 1;
+ EXPECT_CALL(foo, Call()).WillOnce(ReturnRef(value));
+ int& ref = foo.AsStdFunction()();
+ EXPECT_EQ(1, ref);
+ value = 2;
+ EXPECT_EQ(2, ref);
+}
#endif // GTEST_HAS_STD_FUNCTION_
} // namespace gmock_generated_function_mockers_test