aboutsummaryrefslogtreecommitdiff
path: root/src/test/util_tests.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/util_tests.cpp')
-rw-r--r--src/test/util_tests.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp
index b5d8411e1d..269f531a0d 100644
--- a/src/test/util_tests.cpp
+++ b/src/test/util_tests.cpp
@@ -198,6 +198,24 @@ BOOST_AUTO_TEST_CASE(util_HexStr)
BOOST_CHECK_EQUAL(HexStr(in_s), out_exp);
BOOST_CHECK_EQUAL(HexStr(in_b), out_exp);
}
+
+ {
+ auto input = std::string();
+ for (size_t i=0; i<256; ++i) {
+ input.push_back(static_cast<char>(i));
+ }
+
+ auto hex = HexStr(input);
+ BOOST_TEST_REQUIRE(hex.size() == 512);
+ static constexpr auto hexmap = std::string_view("0123456789abcdef");
+ for (size_t i = 0; i < 256; ++i) {
+ auto upper = hexmap.find(hex[i * 2]);
+ auto lower = hexmap.find(hex[i * 2 + 1]);
+ BOOST_TEST_REQUIRE(upper != std::string_view::npos);
+ BOOST_TEST_REQUIRE(lower != std::string_view::npos);
+ BOOST_TEST_REQUIRE(i == upper*16 + lower);
+ }
+ }
}
BOOST_AUTO_TEST_CASE(span_write_bytes)