I am trying to set an "out" parameter on a mock with SetArgPointee
. Here's the code I'm testing:
DWORD bodysize = 1024;
char body[1024];
HRESULT hr = req->ReadEntityBody(body, bodysize, false, &bodysize, NULL);
req
is an IHttpRequest*, and I want to set bodysize
, argument 3, in the mock. Here's the code from my unit test:
EXPECT_CALL(req, ReadEntityBody(NotNull(), Ge(1024), false, NotNull(), _))
.WillOnce(SetArgPointee<3>(4))
.WillOnce(Return(ERROR_HANDLE_EOF));
This results in the following strange error:
error C2440: 'return' : cannot convert from 'void' to 'long' (gmock/gmock-actions.h:369)
If I comment out .WillOnce(SetArgPointee<3>(4))
, the code compiles and executes correctly. Here is the relevant definition in the mock itself:
MOCK_METHOD5(ReadEntityBody, HRESULT(VOID *pvBuffer, DWORD cbBuffer, BOOL fAsync, DWORD *pcbBytesReceived, BOOL *pfCompletionPending));
And, in case it helps, my full mock of IHttpRequest.