65 auto mbsi = mbs.begin();
67 BOOST_CHECK_EQUAL(mb_data(*mbsi), mb.
write_ptr());
69 BOOST_CHECK(mbsi != mbs.end());
71 BOOST_CHECK_NE(mb_data(*mbsi),
nullptr);
73 BOOST_CHECK(mbsi == mbs.end());
80 BOOST_CHECK_NE(mb.
read_ptr(),
nullptr);
86 auto mbsi = mbs.begin();
88 BOOST_CHECK_EQUAL(mb_data(*mbsi), mb.
write_ptr());
90 BOOST_CHECK(mbsi != mbs.end());
92 BOOST_CHECK_NE(mb_data(*mbsi),
nullptr);
94 BOOST_CHECK(mbsi == mbs.end());
255 my_message_buffer_t mbuff;
256 unsigned char stuff[] = {
257 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
259 memcpy(mbuff.write_ptr(), stuff,
sizeof(stuff));
260 mbuff.advance_write_ptr(
sizeof(stuff));
262 my_message_buffer_t::index_t index = mbuff.read_index();
264 mbuff.peek(&throw_away_buffer, 4, index);
265 mbuff.peek(&throw_away_buffer, 4, index);
266 mbuff.peek(&throw_away_buffer, 2, index);
267 BOOST_CHECK_THROW(mbuff.peek(&throw_away_buffer, 3, index), fc::out_of_range_exception);
268 mbuff.peek(&throw_away_buffer, 1, index);
269 mbuff.peek(&throw_away_buffer, 0, index);
270 mbuff.peek(&throw_away_buffer, 1, index);
271 BOOST_CHECK_THROW(mbuff.peek(&throw_away_buffer, 1, index), fc::out_of_range_exception);
273 mbuff.read(&throw_away_buffer, 4);
274 mbuff.read(&throw_away_buffer, 4);
275 mbuff.read(&throw_away_buffer, 2);
276 BOOST_CHECK_THROW(mbuff.read(&throw_away_buffer, 4), fc::out_of_range_exception);
277 mbuff.read(&throw_away_buffer, 1);
278 mbuff.read(&throw_away_buffer, 0);
279 mbuff.read(&throw_away_buffer, 1);
280 BOOST_CHECK_THROW(mbuff.read(&throw_away_buffer, 1), fc::out_of_range_exception);
285 my_message_buffer_t mbuff;
286 unsigned char stuff[] = {
287 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
289 memcpy(mbuff.write_ptr(), stuff, 5);
290 mbuff.advance_write_ptr(5);
291 memcpy(mbuff.write_ptr(), stuff+5, 5);
292 mbuff.advance_write_ptr(5);
293 memcpy(mbuff.write_ptr(), stuff+10, 2);
294 mbuff.advance_write_ptr(2);
296 my_message_buffer_t::index_t index = mbuff.read_index();
298 mbuff.peek(&throw_away_buffer, 4, index);
299 mbuff.peek(&throw_away_buffer, 4, index);
300 mbuff.peek(&throw_away_buffer, 2, index);
301 BOOST_CHECK_THROW(mbuff.peek(&throw_away_buffer, 3, index), fc::out_of_range_exception);
302 mbuff.peek(&throw_away_buffer, 1, index);
303 mbuff.peek(&throw_away_buffer, 0, index);
304 mbuff.peek(&throw_away_buffer, 1, index);
305 BOOST_CHECK_THROW(mbuff.peek(&throw_away_buffer, 1, index), fc::out_of_range_exception);
307 mbuff.read(&throw_away_buffer, 4);
308 mbuff.read(&throw_away_buffer, 4);
309 mbuff.read(&throw_away_buffer, 2);
310 BOOST_CHECK_THROW(mbuff.read(&throw_away_buffer, 4), fc::out_of_range_exception);
311 mbuff.read(&throw_away_buffer, 1);
312 mbuff.read(&throw_away_buffer, 0);
313 mbuff.read(&throw_away_buffer, 1);
314 BOOST_CHECK_THROW(mbuff.read(&throw_away_buffer, 1), fc::out_of_range_exception);
319 my_message_buffer_t mbuff;
331 mbuff.advance_write_ptr(1024);
333 for(
int i = 0; i < 3; ++i ) {
334 auto ds2 = mbuff.create_peek_datastream();
336 BOOST_CHECK_EQUAL( 13, v );
338 BOOST_CHECK_EQUAL( 42, v );
341 BOOST_CHECK_EQUAL(
s, std::string(
"hello" ) );
345 auto ds2 = mbuff.create_datastream();
347 BOOST_CHECK_EQUAL( 13, v );
349 BOOST_CHECK_EQUAL( 42, v );
352 BOOST_CHECK_EQUAL(
s, std::string(
"hello" ) );