MCPcopy Create free account
hub / github.com/boostorg/asio / test_3_arg_mutable_buffer_async_write

Function test_3_arg_mutable_buffer_async_write

test/write.cpp:2223–2282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2221}
2222
2223void test_3_arg_mutable_buffer_async_write()
2224{
2225 namespace bindns = std;
2226 using bindns::placeholders::_1;
2227 using bindns::placeholders::_2;
2228
2229 boost::asio::io_context ioc;
2230 test_stream s(ioc);
2231 boost::asio::mutable_buffer buffers
2232 = boost::asio::buffer(mutable_write_data, sizeof(mutable_write_data));
2233
2234 s.reset();
2235 bool called = false;
2236 boost::asio::async_write(s, buffers,
2237 bindns::bind(async_write_handler,
2238 _1, _2, sizeof(mutable_write_data), &called));
2239 ioc.restart();
2240 ioc.run();
2241 BOOST_ASIO_CHECK(called);
2242 BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
2243
2244 s.reset();
2245 s.next_write_length(1);
2246 called = false;
2247 boost::asio::async_write(s, buffers,
2248 bindns::bind(async_write_handler,
2249 _1, _2, sizeof(mutable_write_data), &called));
2250 ioc.restart();
2251 ioc.run();
2252 BOOST_ASIO_CHECK(called);
2253 BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
2254
2255 s.reset();
2256 s.next_write_length(10);
2257 called = false;
2258 boost::asio::async_write(s, buffers,
2259 bindns::bind(async_write_handler,
2260 _1, _2, sizeof(mutable_write_data), &called));
2261 ioc.restart();
2262 ioc.run();
2263 BOOST_ASIO_CHECK(called);
2264 BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
2265
2266 s.reset();
2267 int i = boost::asio::async_write(s, buffers, archetypes::lazy_handler());
2268 BOOST_ASIO_CHECK(i == 42);
2269 ioc.restart();
2270 ioc.run();
2271 BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
2272
2273 s.reset();
2274 called = false;
2275 boost::asio::async_write(s, buffers)(
2276 bindns::bind(async_write_handler,
2277 _1, _2, sizeof(mutable_write_data), &called));
2278 ioc.restart();
2279 ioc.run();
2280 BOOST_ASIO_CHECK(called);

Callers

nothing calls this directly

Calls 9

bufferFunction · 0.85
async_writeFunction · 0.85
lazy_handlerClass · 0.85
restartMethod · 0.80
bindFunction · 0.50
resetMethod · 0.45
runMethod · 0.45
check_buffersMethod · 0.45
next_write_lengthMethod · 0.45

Tested by

no test coverage detected