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

Function test_3_arg_dynamic_string_async_write

test/write.cpp:2473–2541  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2471}
2472
2473void test_3_arg_dynamic_string_async_write()
2474{
2475 namespace bindns = std;
2476 using bindns::placeholders::_1;
2477 using bindns::placeholders::_2;
2478
2479 boost::asio::io_context ioc;
2480 test_stream s(ioc);
2481 std::string data;
2482 boost::asio::dynamic_string_buffer<char, std::string::traits_type,
2483 std::string::allocator_type> sb
2484 = boost::asio::dynamic_buffer(data, sizeof(write_data));
2485 boost::asio::const_buffer buffers
2486 = boost::asio::buffer(write_data, sizeof(write_data));
2487
2488 s.reset();
2489 data.assign(write_data, sizeof(write_data));
2490 bool called = false;
2491 boost::asio::async_write(s, sb,
2492 bindns::bind(async_write_handler,
2493 _1, _2, sizeof(write_data), &called));
2494 ioc.restart();
2495 ioc.run();
2496 BOOST_ASIO_CHECK(called);
2497 BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
2498
2499 s.reset();
2500 data.assign(write_data, sizeof(write_data));
2501 s.next_write_length(1);
2502 called = false;
2503 boost::asio::async_write(s, sb,
2504 bindns::bind(async_write_handler,
2505 _1, _2, sizeof(write_data), &called));
2506 ioc.restart();
2507 ioc.run();
2508 BOOST_ASIO_CHECK(called);
2509 BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
2510
2511 s.reset();
2512 data.assign(write_data, sizeof(write_data));
2513 s.next_write_length(10);
2514 called = false;
2515 boost::asio::async_write(s, sb,
2516 bindns::bind(async_write_handler,
2517 _1, _2, sizeof(write_data), &called));
2518 ioc.restart();
2519 ioc.run();
2520 BOOST_ASIO_CHECK(called);
2521 BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
2522
2523 s.reset();
2524 data.assign(write_data, sizeof(write_data));
2525 int i = boost::asio::async_write(s, sb, archetypes::lazy_handler());
2526 BOOST_ASIO_CHECK(i == 42);
2527 ioc.restart();
2528 ioc.run();
2529 BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
2530

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected