diff options
author | kosak@google.com <kosak@google.com@8415998a-534a-0410-bf83-d39667b30386> | 2015-07-24 20:05:26 +0000 |
---|---|---|
committer | kosak@google.com <kosak@google.com@8415998a-534a-0410-bf83-d39667b30386> | 2015-07-24 20:05:26 +0000 |
commit | d8a7e6e6f2a70209c412f515bdd6a2e14a5fc1dd (patch) | |
tree | 098f954f33214584c47708af0ad665aec74da20b /test | |
parent | 9d21353a98386f09cd067988d8c7ca2f187bb20b (diff) | |
download | googlemock-d8a7e6e6f2a70209c412f515bdd6a2e14a5fc1dd.tar.gz |
Explicitly specify return value for lambda in AsStdFunction() to ensure it
works properly where return type is a reference.
git-svn-id: http://googlemock.googlecode.com/svn/trunk@548 8415998a-534a-0410-bf83-d39667b30386
Diffstat (limited to 'test')
-rw-r--r-- | test/gmock-generated-function-mockers_test.cc | 10 |
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 18f19d8..a86a613 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 |