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

Function test_3_arg_const_buffer_async_write

test/write.cpp:2162–2221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2160}
2161
2162void test_3_arg_const_buffer_async_write()
2163{
2164 namespace bindns = std;
2165 using bindns::placeholders::_1;
2166 using bindns::placeholders::_2;
2167
2168 boost::asio::io_context ioc;
2169 test_stream s(ioc);
2170 boost::asio::const_buffer buffers
2171 = boost::asio::buffer(write_data, sizeof(write_data));
2172
2173 s.reset();
2174 bool called = false;
2175 boost::asio::async_write(s, buffers,
2176 bindns::bind(async_write_handler,
2177 _1, _2, sizeof(write_data), &called));
2178 ioc.restart();
2179 ioc.run();
2180 BOOST_ASIO_CHECK(called);
2181 BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
2182
2183 s.reset();
2184 s.next_write_length(1);
2185 called = false;
2186 boost::asio::async_write(s, buffers,
2187 bindns::bind(async_write_handler,
2188 _1, _2, sizeof(write_data), &called));
2189 ioc.restart();
2190 ioc.run();
2191 BOOST_ASIO_CHECK(called);
2192 BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
2193
2194 s.reset();
2195 s.next_write_length(10);
2196 called = false;
2197 boost::asio::async_write(s, buffers,
2198 bindns::bind(async_write_handler,
2199 _1, _2, sizeof(write_data), &called));
2200 ioc.restart();
2201 ioc.run();
2202 BOOST_ASIO_CHECK(called);
2203 BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
2204
2205 s.reset();
2206 int i = boost::asio::async_write(s, buffers, archetypes::lazy_handler());
2207 BOOST_ASIO_CHECK(i == 42);
2208 ioc.restart();
2209 ioc.run();
2210 BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
2211
2212 s.reset();
2213 called = false;
2214 boost::asio::async_write(s, buffers)(
2215 bindns::bind(async_write_handler,
2216 _1, _2, sizeof(write_data), &called));
2217 ioc.restart();
2218 ioc.run();
2219 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