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

Function test_3_arg_streambuf_async_write

test/write.cpp:2543–2616  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2541}
2542
2543void test_3_arg_streambuf_async_write()
2544{
2545#if !defined(BOOST_ASIO_NO_DYNAMIC_BUFFER_V1)
2546 namespace bindns = std;
2547 using bindns::placeholders::_1;
2548 using bindns::placeholders::_2;
2549
2550 boost::asio::io_context ioc;
2551 test_stream s(ioc);
2552 boost::asio::streambuf sb;
2553 boost::asio::const_buffer buffers
2554 = boost::asio::buffer(write_data, sizeof(write_data));
2555
2556 s.reset();
2557 sb.consume(sb.size());
2558 sb.sputn(write_data, sizeof(write_data));
2559 bool called = false;
2560 boost::asio::async_write(s, sb,
2561 bindns::bind(async_write_handler,
2562 _1, _2, sizeof(write_data), &called));
2563 ioc.restart();
2564 ioc.run();
2565 BOOST_ASIO_CHECK(called);
2566 BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
2567
2568 s.reset();
2569 sb.consume(sb.size());
2570 sb.sputn(write_data, sizeof(write_data));
2571 s.next_write_length(1);
2572 called = false;
2573 boost::asio::async_write(s, sb,
2574 bindns::bind(async_write_handler,
2575 _1, _2, sizeof(write_data), &called));
2576 ioc.restart();
2577 ioc.run();
2578 BOOST_ASIO_CHECK(called);
2579 BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
2580
2581 s.reset();
2582 sb.consume(sb.size());
2583 sb.sputn(write_data, sizeof(write_data));
2584 s.next_write_length(10);
2585 called = false;
2586 boost::asio::async_write(s, sb,
2587 bindns::bind(async_write_handler,
2588 _1, _2, sizeof(write_data), &called));
2589 ioc.restart();
2590 ioc.run();
2591 BOOST_ASIO_CHECK(called);
2592 BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
2593
2594 s.reset();
2595 sb.consume(sb.size());
2596 sb.sputn(write_data, sizeof(write_data));
2597 int i = boost::asio::async_write(s, sb, archetypes::lazy_handler());
2598 BOOST_ASIO_CHECK(i == 42);
2599 ioc.restart();
2600 ioc.run();

Callers

nothing calls this directly

Calls 11

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

Tested by

no test coverage detected