1#include <xrpl/basics/Slice.h>
3#include <gtest/gtest.h>
12 0xa8, 0xa1, 0x38, 0x45, 0x23, 0xec, 0xe4, 0x23, 0x71, 0x6d, 0x2a, 0x18, 0xb4, 0x70, 0xcb, 0xf5,
13 0xac, 0x2d, 0x89, 0x4d, 0x19, 0x9c, 0xf0, 0x2c, 0x15, 0xd1, 0xf9, 0x9b, 0x66, 0xd2, 0x30, 0xd3};
15TEST(
Slice, equality_and_inequality)
19 EXPECT_EQ(s0.
size(), 0);
20 EXPECT_EQ(s0.
data(),
nullptr);
26 Slice const s1{kData, i};
28 EXPECT_EQ(s1.
size(), i);
29 EXPECT_NE(s1.
data(),
nullptr);
42 Slice const s2{kData, j};
60 a[i] = b[i] = kData[i];
71 Slice const s{kData,
sizeof(kData)};
74 EXPECT_EQ(s[i], kData[i]);
83 Slice s(kData + i,
sizeof(kData) - i);
86 EXPECT_EQ(s.
data(), kData + i + j);
87 EXPECT_EQ(s.
size(),
sizeof(kData) - i - j);
An immutable linear range of bytes.
std::uint8_t const * data() const noexcept
Return a pointer to beginning of the storage.
std::size_t size() const noexcept
Returns the number of bytes in the storage.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::enable_if_t< std::is_same_v< T, char >||std::is_same_v< T, unsigned char >, Slice > makeSlice(std::array< T, N > const &a)