I'm using gmock and have mocked a function that takes boost::beast::http::response_parser as an out parameter. Function signature looks something like:
error_code readFromSocket(boost::beast::http::response_parser& resp);
Now, to test this function, I mocked and use EXPECT_CALL
like:
boost::beast::http::response_parser respObject;
// set status code in respObject
EXPECT_CALL(mockObject, readFromSocket(_))
.Times(1)
.DoAll(SetArgReferee<0>(respObject), Return(err::success));
And it returns me an operator= deleted compilation
error. I have tried
various combinations using ByRef
, ByMove
, using std::ref
but none of them
works and I understand why they don't work.
Has anyone ever ran into a similar situation before and know how to solve this error? Please let me know if you need clarification.
Thank you.
EDIT
This is what readFromSocket
looks like:
template<typename T>
error_code readFromSocket(beast::http::response_parser<T>& resp,
boost::asio::yield_context yield)
{
// read from socket using beast::http::async_read
return success;
}
This is how I call it.
beast::http::response_parser<beast::http::string_body> resp;
resp.body_limit((std::numeric_limits<std::string::size_type>::max)());
auto ec = readFromSocket(resp, yield);
// after this I do error handling and response status code handling.