xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
tests
libxrpl
protocol
tests/libxrpl/protocol/Serializer.cpp
1
#include <xrpl/protocol/Serializer.h>
2
3
#include <gtest/gtest.h>
4
5
#include <
array
>
6
#include <
cstdint
>
7
#include <
limits
>
8
9
using namespace
xrpl
;
10
11
TEST
(
Serializer
, add32_roundtrip)
12
{
13
static
constexpr
auto
kValues = std::to_array<std::int32_t>({
14
std::numeric_limits<std::int32_t>::min
(),
15
-1,
16
0,
17
1,
18
std::numeric_limits<std::int32_t>::max
(),
19
});
20
21
for
(
std::int32_t
const
value : kValues)
22
{
23
Serializer
s;
24
s.
add32
(value);
25
EXPECT_EQ(s.
size
(), 4);
26
SerialIter
sit(s.
slice
());
27
EXPECT_EQ(sit.geti32(), value);
28
}
29
}
30
31
TEST
(
Serializer
, add64_roundtrip)
32
{
33
static
constexpr
auto
kValues = std::to_array<std::int64_t>({
34
std::numeric_limits<std::int64_t>::min
(),
35
-1,
36
0,
37
1,
38
std::numeric_limits<std::int64_t>::max
(),
39
});
40
41
for
(
std::int64_t
const
value : kValues)
42
{
43
Serializer
s;
44
s.
add64
(value);
45
EXPECT_EQ(s.
size
(), 8);
46
SerialIter
sit(s.
slice
());
47
EXPECT_EQ(sit.geti64(), value);
48
}
49
}
array
xrpl::SerialIter
Definition
Serializer.h:478
xrpl::Serializer
Definition
Serializer.h:23
xrpl::Serializer::add64
int add64(T i)
Definition
Serializer.h:183
xrpl::Serializer::slice
Slice slice() const noexcept
Definition
Serializer.h:141
xrpl::Serializer::add32
int add32(T i)
Definition
Serializer.h:167
xrpl::Serializer::size
std::size_t size() const noexcept
Definition
Serializer.h:147
cstdint
std::int32_t
limits
std::numeric_limits::max
T max(T... args)
std::numeric_limits::min
T min(T... args)
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::TEST
TEST(FileUtilitiesTest, get_file_contents)
Definition
tests/libxrpl/basics/FileUtilities.cpp:60
Generated by
1.17.0