I am trying to set a class member function parameter value in Google Mock, but I get build errors and I simply don't understand what is going on. Would it be possible for someone to explain please.
The function prototype is:
virtual int recv( Socket socket
, char *buffer
, int bufferLength
, int flags ) = 0;
I am trying to test it using:
TEST_F( IPV4SocketTests, Read_SockErr_ok )
{
Mock_SocketAdaptor *adaptor = new Mock_SocketAdaptor;
char *rcvBuffer = "testingRcvWorks";
EXPECT_CALL( *adaptor, recv( testing::_, testing::_, testing::_, testing::_ ) )
.WillRepeatedly( testing::DoAll(
testing::SetArgPointee<1>( rcvBuffer ),
testing::Return( strlen( rcvBuffer ) ) ) );
The error I am getting is regarding conversion from std::get.
testing::SetArgPointee<1>( rcvBuffer )
supposed to achieve? The second/first parametre you passed is just testing::_, so you won't have access to it anyway. – Centrifugatetesting::_
indicates that this parameter won't be matched with some value, there is nothing that preventsSetArgPointee
to work like Paul intended. – Vitality