@@ -54,7 +54,8 @@ struct BasicStubbing : tpunit::TestFixture {
5454 TEST(BasicStubbing::exception_while_stubbing_should_cancel_stubbing),
5555 TEST(BasicStubbing::reset_mock_to_initial_state),
5656 TEST(BasicStubbing::use_lambda_to_change_ptr_value),
57- TEST(BasicStubbing::assingOutParamsWithLambda)
57+ TEST(BasicStubbing::assingOutParamsWithLambda),
58+ TEST(BasicStubbing::return_ref_to_lambda_member)
5859 ) {
5960 }
6061
@@ -63,6 +64,7 @@ struct BasicStubbing : tpunit::TestFixture {
6364 virtual int funcNoArgs () = 0;
6465 virtual int funcRefArgs (int *, int &) = 0;
6566 virtual int funcConvertibleNotAssignableArgs1 (int &, int ) = 0;
67+ virtual const std::string& funcRetStrRef (int ) = 0;
6668
6769 virtual void proc (int ) = 0;
6870 virtual void procRefArgs (int *, int &) = 0;
@@ -868,5 +870,18 @@ struct BasicStubbing : tpunit::TestFixture {
868870 ASSERT_EQUAL (3 ,result);
869871 }
870872
873+ void return_ref_to_lambda_member () {
874+ Mock<SomeInterface> mock;
875+
876+ std::string str = " Some string with some content inside it" ;
877+ When (Method (mock, funcRetStrRef)).Do ([str](int ) -> const std::string& {return str;});
878+
879+ SomeInterface& i = mock.get ();
880+
881+ ASSERT_EQUAL (i.funcRetStrRef (5 ), str);
882+
883+ ASSERT_THROW (i.funcRetStrRef (5 ), fakeit::UnexpectedMethodCallException);
884+ }
885+
871886} __BasicStubbing;
872887
0 commit comments