View | Details | Raw Unified | Return to bug 1001
Collapse All | Expand All

(-)a/src/network/test/buffer-test.cc (+20 lines)
 Lines 298-303    Link Here 
298
  i = other.Begin ();
298
  i = other.Begin ();
299
  i.Write (buffer.Begin (), buffer.End ());
299
  i.Write (buffer.Begin (), buffer.End ());
300
  ENSURE_WRITTEN_BYTES (other, 9, 0x1, 0x2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3, 0x4);
300
  ENSURE_WRITTEN_BYTES (other, 9, 0x1, 0x2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3, 0x4);
301
302
  // BUG #1001
303
  std::string ct ("This is the next content of the buffer.");
304
  buffer = Buffer ();
305
  buffer.AddAtStart (ct.size ());
306
  i = buffer.Begin ();
307
  i.Write ((const uint8_t*)ct.c_str (), ct.size ());
308
  uint32_t sizeBuffer = buffer.GetSize ();
309
  NS_TEST_ASSERT_MSG_EQ (sizeBuffer, ct.size(), "Buffer bad size");
310
  uint8_t const* evilBuffer = buffer.PeekData ();
311
  NS_TEST_ASSERT_MSG_NE( evilBuffer, 0, "Buffer PeekData failed");
312
  uint8_t *cBuf = (uint8_t*) malloc ( sizeBuffer );
313
  uint32_t copyLen = buffer.CopyData (cBuf, sizeBuffer);
314
  NS_TEST_ASSERT_MSG_EQ (copyLen, sizeBuffer, "CopyData return bad size");
315
  for (uint8_t i=0; i < sizeBuffer ; i++ )
316
    {
317
      NS_TEST_ASSERT_MSG_EQ ( cBuf [i], *(((const uint8_t*)ct.c_str ()) + i), "Bad buffer copied data");
318
      NS_TEST_ASSERT_MSG_EQ ( evilBuffer [i], cBuf [i] , "Bad buffer peeked");
319
    }
320
301
}
321
}
302
//-----------------------------------------------------------------------------
322
//-----------------------------------------------------------------------------
303
class BufferTestSuite : public TestSuite
323
class BufferTestSuite : public TestSuite

Return to bug 1001