21 #include "ns3/buffer.h" 
   22 #include "ns3/random-variable-stream.h" 
   23 #include "ns3/double.h" 
   33   void EnsureWrittenBytes (
Buffer b, uint32_t n, uint8_t array[], 
const char *file, 
int line);
 
   35   virtual void DoRun (
void);
 
   48   uint8_t *expected = array;
 
   51   for (uint32_t j = 0; j < n; j++) 
 
   53       if (got[j] != expected[j]) 
 
   60       std::ostringstream failure;
 
   61       failure << 
"Buffer -- ";
 
   62       failure << 
"expected: n=";
 
   64       failure.setf (std::ios::hex, std::ios::basefield);
 
   65       for (uint32_t j = 0; j < n; j++) 
 
   67           failure << (uint16_t)expected[j] << 
" ";
 
   69       failure.setf (std::ios::dec, std::ios::basefield);
 
   71       failure.setf (std::ios::hex, std::ios::basefield);
 
   72       for (uint32_t j = 0; j < n; j++) 
 
   74           failure << (uint16_t)got[j] << 
" ";
 
   84 #define ENSURE_WRITTEN_BYTES(buffer, n, ...)                    \ 
   86     uint8_t bytes[] = { __VA_ARGS__};                            \ 
   87     EnsureWrittenBytes (buffer, n, bytes, __FILE__, __LINE__);  \ 
  117   ENSURE_WRITTEN_BYTES (buffer, 10, 0, 0, 0x63, 0x69, 0xde, 0xad, 0xbe, 0xaf, 0, 0);
 
  196   i.WriteHtonU32 (0xdeadbeaf);
 
  230   ENSURE_WRITTEN_BYTES (buffer, 11, 0x30, 0x31, 0x32, 0, 0, 0xac, 0xad, 0xae, 0xaf, 0xba, 0xbb);
 
  237   i.WriteHtonU16 (0xabcd);
 
  245   buffer.AddAtStart (9);
 
  252   buffer.AddAtStart (3);
 
  253   buffer.RemoveAtEnd (8);
 
  260   buffer.AddAtEnd (100);
 
  268     const uint32_t actualSize = 72602;
 
  269     const uint32_t chunkSize = 67624;
 
  280       for (uint32_t i = 0; i < actualSize; i++)
 
  286     iter.
Prev (chunkSize);
 
  308   buffer.AddAtStart (2);
 
  317   ENSURE_WRITTEN_BYTES (buffer, 9, 0x1, 0x2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3, 0x4);
 
  321   i.
Write (buffer.Begin (), buffer.End ());
 
  322   ENSURE_WRITTEN_BYTES (other, 9, 0x1, 0x2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3, 0x4);
 
  325   std::string ct (
"This is the next content of the buffer.");
 
  327   buffer.AddAtStart (ct.size ());
 
  329   i.Write ((
const uint8_t*)ct.c_str (), ct.size ());
 
  330   uint32_t sizeBuffer = buffer.GetSize ();
 
  332   uint8_t 
const* evilBuffer = buffer.PeekData ();
 
  334   uint8_t *cBuf = (uint8_t*) malloc ( sizeBuffer );
 
  335   uint32_t copyLen = buffer.CopyData (cBuf, sizeBuffer);
 
  337   for (uint8_t i=0; i < sizeBuffer ; i++ )
 
  354   uint16_t val1 = i.ReadNtohU16 ();
 
void WriteHtonU64(uint64_t data)
 
void AddAtStart(uint32_t start)
 
#define ENSURE_WRITTEN_BYTES(buffer, n,...)
 
void RemoveAtEnd(uint32_t end)
 
void RemoveAtStart(uint32_t start)
 
automatically resized byte buffer 
 
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not. 
 
void EnsureWrittenBytes(Buffer b, uint32_t n, uint8_t array[], const char *file, int line)
 
#define NS_TEST_ASSERT_MSG_EQ_INTERNAL(actual, limit, msg, file, line)
Test that an actual and expected (limit) value are equal and report and abort if not. 
 
iterator in a Buffer instance 
 
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite. 
 
void Prev(void)
go backward by one byte 
 
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not. 
 
void WriteU16(uint16_t data)
 
void WriteHtonU16(uint16_t data)
 
Buffer::Iterator End(void) const 
 
uint8_t const * PeekData(void) const 
 
void Next(void)
go forward by one byte 
 
void WriteU64(uint64_t data)
 
Buffer::Iterator Begin(void) const 
 
void AddAtEnd(uint32_t end)
 
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
 
virtual void DoRun(void)
Implementation to actually run this TestCase. 
 
void WriteHtonU32(uint32_t data)
 
uint32_t GetSize(void) const 
 
Buffer CreateFragment(uint32_t start, uint32_t length) const 
 
void WriteU8(uint8_t data)
 
#define NS_TEST_ASSERT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report and abort if not...
 
void WriteHtolsbU64(uint64_t data)
 
void Write(uint8_t const *buffer, uint32_t size)
 
uint16_t ReadNtohU16(void)
 
This class can be used to hold variables of floating point type such as 'double' or 'float'...
 
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful. 
 
static BufferTestSuite g_bufferTestSuite