21 #include "ns3/buffer.h"
22 #include "ns3/random-variable-stream.h"
23 #include "ns3/double.h"
49 void EnsureWrittenBytes (
Buffer b, uint32_t
n, uint8_t array[],
const char *
file,
int line);
51 virtual void DoRun (
void);
64 uint8_t *expected = array;
67 for (uint32_t j = 0; j <
n; j++)
69 if (got[j] != expected[j])
76 std::ostringstream failure;
77 failure <<
"Buffer -- ";
78 failure <<
"expected: n=";
80 failure.setf (std::ios::hex, std::ios::basefield);
81 for (uint32_t j = 0; j <
n; j++)
83 failure << (uint16_t)expected[j] <<
" ";
85 failure.setf (std::ios::dec, std::ios::basefield);
87 failure.setf (std::ios::hex, std::ios::basefield);
88 for (uint32_t j = 0; j <
n; j++)
90 failure << (uint16_t)got[j] <<
" ";
101 #define ENSURE_WRITTEN_BYTES(buffer, n, ...) \
103 uint8_t bytes[] = { __VA_ARGS__}; \
104 EnsureWrittenBytes (buffer, n, bytes, __FILE__, __LINE__); \
134 ENSURE_WRITTEN_BYTES (buffer, 10, 0, 0, 0x63, 0x69, 0xde, 0xad, 0xbe, 0xaf, 0, 0);
192 #if defined(__clang__)
193 #if __has_warning("-Wself-assign-overloaded")
194 #pragma clang diagnostic push
195 #pragma clang diagnostic ignored "-Wself-assign-overloaded"
199 #if defined(__clang__)
200 #if __has_warning("-Wself-assign-overloaded")
201 #pragma clang diagnostic pop
258 ENSURE_WRITTEN_BYTES (buffer, 11, 0x30, 0x31, 0x32, 0, 0, 0xac, 0xad, 0xae, 0xaf, 0xba, 0xbb);
296 const uint32_t actualSize = 72602;
297 const uint32_t chunkSize = 67624;
308 for (uint32_t i = 0; i < actualSize; i++)
314 iter.
Prev (chunkSize);
345 ENSURE_WRITTEN_BYTES (buffer, 9, 0x1, 0x2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3, 0x4);
350 ENSURE_WRITTEN_BYTES (other, 9, 0x1, 0x2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3, 0x4);
353 std::string ct (
"This is the next content of the buffer.");
357 i.
Write ((
const uint8_t*)ct.c_str (), ct.size ());
358 uint32_t sizeBuffer = buffer.
GetSize ();
360 uint8_t
const* evilBuffer = buffer.
PeekData ();
362 uint8_t *cBuf = (uint8_t*) malloc ( sizeBuffer );
363 uint32_t copyLen = buffer.
CopyData (cBuf, sizeBuffer);
365 for (uint8_t i=0; i < sizeBuffer ; i++ )