Add to_hex::buffer

This commit is contained in:
Lee *!* Clagett 2023-05-21 13:41:27 -04:00
parent 94e67bf96b
commit eb943562cb
3 changed files with 27 additions and 0 deletions

View file

@ -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;