inline std::string
Digest::to_string() const
{
- return Util::format_hex(m_bytes, size());
+ return Util::format_base16(m_bytes, size());
}
inline bool
switch (hash_type) {
case HashType::binary:
- add_debug_text(Util::format_hex(static_cast<const uint8_t*>(data), size));
+ add_debug_text(
+ Util::format_base16(static_cast<const uint8_t*>(data), size));
break;
case HashType::text:
}
std::string
-format_hex(const uint8_t* data, size_t size)
+format_base16(const uint8_t* data, size_t size)
{
static const char digits[] = "0123456789abcdef";
std::string result;
// Format a hexadecimal string representing `size` bytes of `data`. The returned
// string will be `2 * size` long.
-std::string format_hex(const uint8_t* data, size_t size);
+std::string format_base16(const uint8_t* data, size_t size);
// Format `size` as a human-readable string.
std::string format_human_readable_size(uint64_t size);
CHECK(Util::format_argv_for_logging(argv_2) == "foo bar");
}
-TEST_CASE("Util::format_hex")
+TEST_CASE("Util::format_base16")
{
uint8_t none[] = "";
uint8_t text[4] = "foo"; // incl. NUL
uint8_t data[4] = {0, 1, 2, 3};
- CHECK(Util::format_hex(none, 0) == "");
- CHECK(Util::format_hex(text, sizeof(text)) == "666f6f00");
- CHECK(Util::format_hex(data, sizeof(data)) == "00010203");
+ CHECK(Util::format_base16(none, 0) == "");
+ CHECK(Util::format_base16(text, sizeof(text)) == "666f6f00");
+ CHECK(Util::format_base16(data, sizeof(data)) == "00010203");
}
TEST_CASE("Util::format_human_readable_size")