diff options
author | Lee *!* Clagett <code@leeclagett.com> | 2023-05-21 13:41:27 -0400 |
---|---|---|
committer | Lee *!* Clagett <code@leeclagett.com> | 2023-05-22 13:36:05 -0400 |
commit | eb943562cba9612709e592db279d270b916c0b66 (patch) | |
tree | ffbc8c328b0186ebe2dfc219d098d1855ac55c26 /tests/unit_tests/epee_utils.cpp | |
parent | Merge pull request #8842 (diff) | |
download | monero-eb943562cba9612709e592db279d270b916c0b66.tar.xz |
Add to_hex::buffer
Diffstat (limited to '')
-rw-r--r-- | tests/unit_tests/epee_utils.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/unit_tests/epee_utils.cpp b/tests/unit_tests/epee_utils.cpp index 185cb73b1..c776fbcc9 100644 --- a/tests/unit_tests/epee_utils.cpp +++ b/tests/unit_tests/epee_utils.cpp @@ -1241,6 +1241,22 @@ TEST(ToHex, ArrayFromPod) ); } +TEST(ToHex, Buffer) +{ + static constexpr const std::uint8_t source[] = {0xFF, 0x00, 0xAB, 0x01}; + const std::vector<char> expected{'f', 'f', '0', '0', 'a', 'b', '0', '1'}; + + std::vector<char> buffer; + buffer.resize(expected.size()); + EXPECT_TRUE(epee::to_hex::buffer(epee::to_mut_span(buffer), source)); + EXPECT_EQ(expected, buffer); + + buffer.pop_back(); + EXPECT_FALSE(epee::to_hex::buffer(epee::to_mut_span(buffer), source)); + buffer.pop_back(); + EXPECT_FALSE(epee::to_hex::buffer(epee::to_mut_span(buffer), source)); +} + TEST(ToHex, Ostream) { std::stringstream out; |