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

Function test_3_arg_vector_buffers_async_write

test/write.cpp:2410–2471  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2408}
2409
2410void test_3_arg_vector_buffers_async_write()
2411{
2412 namespace bindns = std;
2413 using bindns::placeholders::_1;
2414 using bindns::placeholders::_2;
2415
2416 boost::asio::io_context ioc;
2417 test_stream s(ioc);
2418 std::vector<boost::asio::const_buffer> buffers;
2419 buffers.push_back(boost::asio::buffer(write_data, 32));
2420 buffers.push_back(boost::asio::buffer(write_data, 39) + 32);
2421 buffers.push_back(boost::asio::buffer(write_data) + 39);
2422
2423 s.reset();
2424 bool called = false;
2425 boost::asio::async_write(s, buffers,
2426 bindns::bind(async_write_handler,
2427 _1, _2, sizeof(write_data), &called));
2428 ioc.restart();
2429 ioc.run();
2430 BOOST_ASIO_CHECK(called);
2431 BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
2432
2433 s.reset();
2434 s.next_write_length(1);
2435 called = false;
2436 boost::asio::async_write(s, buffers,
2437 bindns::bind(async_write_handler,
2438 _1, _2, sizeof(write_data), &called));
2439 ioc.restart();
2440 ioc.run();
2441 BOOST_ASIO_CHECK(called);
2442 BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
2443
2444 s.reset();
2445 s.next_write_length(10);
2446 called = false;
2447 boost::asio::async_write(s, buffers,
2448 bindns::bind(async_write_handler,
2449 _1, _2, sizeof(write_data), &called));
2450 ioc.restart();
2451 ioc.run();
2452 BOOST_ASIO_CHECK(called);
2453 BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
2454
2455 s.reset();
2456 int i = boost::asio::async_write(s, buffers, archetypes::lazy_handler());
2457 BOOST_ASIO_CHECK(i == 42);
2458 ioc.restart();
2459 ioc.run();
2460 BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
2461
2462 s.reset();
2463 called = false;
2464 boost::asio::async_write(s, buffers)(
2465 bindns::bind(async_write_handler,
2466 _1, _2, sizeof(write_data), &called));
2467 ioc.restart();

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