aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLee *!* Clagett <code@leeclagett.com>2023-05-21 13:41:27 -0400
committerLee *!* Clagett <code@leeclagett.com>2023-05-22 13:36:05 -0400
commiteb943562cba9612709e592db279d270b916c0b66 (patch)
treeffbc8c328b0186ebe2dfc219d098d1855ac55c26 /tests
parentMerge pull request #8842 (diff)
downloadmonero-eb943562cba9612709e592db279d270b916c0b66.tar.xz
Add to_hex::buffer
Diffstat (limited to 'tests')
-rw-r--r--tests/unit_tests/epee_utils.cpp16
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;