MCPcopy Create free account
hub / github.com/boostorg/beast / testBuffer

Method testBuffer

test/beast/core/buffer_ref.cpp:33–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31
32 template<typename Buffer>
33 void testBuffer()
34 {
35 net::io_context ioc;
36 net::readable_pipe rp{ioc};
37 net::writable_pipe wp{ioc};
38 net::connect_pipe(rp, wp);
39
40 const char msg[] = "Hello, world!\n";
41
42 net::async_write(wp, net::buffer(msg), asio::detached);
43
44 Buffer buf;
45
46 net::async_read_until(rp, ref(buf), '\n', asio::detached);
47 ioc.run();
48 // writable, not commited yet!
49 std::string cmp;
50 cmp.resize(sizeof(msg) -1);
51 const auto n = net::buffer_copy(net::buffer(cmp), buf.data());
52 BEAST_EXPECT(n >= std::strlen(msg));
53 cmp.resize(13);
54 BEAST_EXPECT(cmp == "Hello, world!");
55
56
57 buf = Buffer();
58 test_dynamic_buffer_ref(ref(buf));
59 }
60
61 void
62 run() override

Callers

nothing calls this directly

Calls 5

refFunction · 0.85
test_dynamic_buffer_refFunction · 0.85
async_writeFunction · 0.50
runMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected