From: Joel Rosdahl Date: Mon, 21 Sep 2020 19:57:05 +0000 (+0200) Subject: Rename Util::format_hex to format_base16 X-Git-Tag: v4.0~68 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f6932174161e5d686f16dead034c03ba2910619d;p=thirdparty%2Fccache.git Rename Util::format_hex to format_base16 --- diff --git a/src/Digest.hpp b/src/Digest.hpp index 627088c37..f20684f16 100644 --- a/src/Digest.hpp +++ b/src/Digest.hpp @@ -72,7 +72,7 @@ Digest::size() inline std::string Digest::to_string() const { - return Util::format_hex(m_bytes, size()); + return Util::format_base16(m_bytes, size()); } inline bool diff --git a/src/Hash.cpp b/src/Hash.cpp index c5b135aaf..bb186b70e 100644 --- a/src/Hash.cpp +++ b/src/Hash.cpp @@ -74,7 +74,8 @@ Hash::hash(const void* data, size_t size, HashType hash_type) switch (hash_type) { case HashType::binary: - add_debug_text(Util::format_hex(static_cast(data), size)); + add_debug_text( + Util::format_base16(static_cast(data), size)); break; case HashType::text: diff --git a/src/Util.cpp b/src/Util.cpp index 99eaf7880..154a942d3 100644 --- a/src/Util.cpp +++ b/src/Util.cpp @@ -522,7 +522,7 @@ format_argv_for_logging(const char* const* argv) } 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; diff --git a/src/Util.hpp b/src/Util.hpp index 01847ecc3..2876b7012 100644 --- a/src/Util.hpp +++ b/src/Util.hpp @@ -168,7 +168,7 @@ std::string format_argv_for_logging(const char* const* argv); // 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); diff --git a/unittest/test_Util.cpp b/unittest/test_Util.cpp index 3c5c49766..cf3e56497 100644 --- a/unittest/test_Util.cpp +++ b/unittest/test_Util.cpp @@ -273,15 +273,15 @@ TEST_CASE("Util::format_argv_for_logging") 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")