xrpld
Loading...
Searching...
No Matches
xrpl::test::BufferTest Struct Reference
Inheritance diagram for xrpl::test::BufferTest:
Collaboration diagram for xrpl::test::BufferTest:

Static Public Member Functions

static bool sane (Buffer const &b)
static void checkEmptyAfterMove (Buffer const &buf)
 Check the state Buffer documents for a moved-from buffer: "the other buffer is reset", i.e.

Public Attributes

Buffer const emptyBuffer
Buffer const firstHalf {kRandomData.data(), kHalf}
Buffer const secondHalf {kRandomData.data() + kHalf, kHalf}
Buffer const whole {kRandomData.data(), kRandomData.size()}

Static Public Attributes

static constexpr auto kRandomData
static constexpr std::size_t kHalf = kRandomData.size() / 2

Detailed Description

Definition at line 19 of file Buffer.cpp.

Member Function Documentation

◆ sane()

bool xrpl::test::BufferTest::sane ( Buffer const & b)
static

Definition at line 29 of file Buffer.cpp.

◆ checkEmptyAfterMove()

void xrpl::test::BufferTest::checkEmptyAfterMove ( Buffer const & buf)
static

Check the state Buffer documents for a moved-from buffer: "the other buffer is reset", i.e.

empty and sane.

Zeroing the size is not incidental tidiness. Moving the member unique_ptr nulls the data pointer whether Buffer wants it or not, so a moved-from buffer that kept its old size would lie about itself everywhere: alloc() would take its n == size_ early-out and hand back a null pointer while still reporting the old size, fill() would run std::fill_n over a null pointer, and the Slice conversion would publish {nullptr, oldSize} to callers. A moved-from Buffer has to be a usable empty Buffer rather than a landmine, which is why the tests below assert this state instead of treating a moved-from buffer as untouchable.

Definition at line 50 of file Buffer.cpp.

Member Data Documentation

◆ kRandomData

auto xrpl::test::BufferTest::kRandomData
staticconstexpr
Initial value:
= std::to_array<std::uint8_t>(
{0xa8, 0xa1, 0x38, 0x45, 0x23, 0xec, 0xe4, 0x23, 0x71, 0x6d, 0x2a,
0x18, 0xb4, 0x70, 0xcb, 0xf5, 0xac, 0x2d, 0x89, 0x4d, 0x19, 0x9c,
0xf0, 0x2c, 0x15, 0xd1, 0xf9, 0x9b, 0x66, 0xd2, 0x30, 0xd3})

Definition at line 21 of file Buffer.cpp.

◆ kHalf

std::size_t xrpl::test::BufferTest::kHalf = kRandomData.size() / 2
staticconstexpr

Definition at line 26 of file Buffer.cpp.

◆ emptyBuffer

Buffer const xrpl::test::BufferTest::emptyBuffer

Definition at line 56 of file Buffer.cpp.

◆ firstHalf

Buffer const xrpl::test::BufferTest::firstHalf {kRandomData.data(), kHalf}

Definition at line 57 of file Buffer.cpp.

◆ secondHalf

Buffer const xrpl::test::BufferTest::secondHalf {kRandomData.data() + kHalf, kHalf}

Definition at line 58 of file Buffer.cpp.

◆ whole

Buffer const xrpl::test::BufferTest::whole {kRandomData.data(), kRandomData.size()}

Definition at line 59 of file Buffer.cpp.