| 43 | } |
| 44 | |
| 45 | void |
| 46 | testMembers() |
| 47 | { |
| 48 | string_view const s = "Hello, world!"; |
| 49 | |
| 50 | // static_buffer_base |
| 51 | { |
| 52 | char buf[64]; |
| 53 | static_buffer_base b{buf, sizeof(buf)}; |
| 54 | ostream(b) << s; |
| 55 | BEAST_EXPECT(buffers_to_string(b.data()) == s); |
| 56 | b.clear(); |
| 57 | BEAST_EXPECT(b.size() == 0); |
| 58 | BEAST_EXPECT(buffer_bytes(b.data()) == 0); |
| 59 | } |
| 60 | |
| 61 | // static_buffer |
| 62 | { |
| 63 | static_buffer<64> b1; |
| 64 | BEAST_EXPECT(b1.size() == 0); |
| 65 | BEAST_EXPECT(b1.max_size() == 64); |
| 66 | BEAST_EXPECT(b1.capacity() == 64); |
| 67 | ostream(b1) << s; |
| 68 | BEAST_EXPECT(buffers_to_string(b1.data()) == s); |
| 69 | { |
| 70 | static_buffer<64> b2{b1}; |
| 71 | BEAST_EXPECT(buffers_to_string(b2.data()) == s); |
| 72 | b2.consume(7); |
| 73 | BEAST_EXPECT(buffers_to_string(b2.data()) == s.substr(7)); |
| 74 | } |
| 75 | { |
| 76 | static_buffer<64> b2; |
| 77 | b2 = b1; |
| 78 | BEAST_EXPECT(buffers_to_string(b2.data()) == s); |
| 79 | b2.consume(7); |
| 80 | BEAST_EXPECT(buffers_to_string(b2.data()) == s.substr(7)); |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | // cause memmove |
| 85 | { |
| 86 | static_buffer<10> b; |
| 87 | ostream(b) << "12345"; |
| 88 | b.consume(3); |
| 89 | ostream(b) << "67890123"; |
| 90 | BEAST_EXPECT(buffers_to_string(b.data()) == "4567890123"); |
| 91 | try |
| 92 | { |
| 93 | b.prepare(1); |
| 94 | fail("", __FILE__, __LINE__); |
| 95 | } |
| 96 | catch(std::length_error const&) |
| 97 | { |
| 98 | pass(); |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | // read_size |
nothing calls this directly
no test coverage detected