test: Redeclare variable as signed in util_tests

Assigning `ToIntegral<int64_t>("-1")` to the `optional<uint64_t>` `n`
is a silent underflow. `BOOST_CHECK_EQUAL` then promotes `int` to
`uint64_t`, which also underflows. The correct check is to do this
inline.
This commit is contained in:
rustaceanrob
2026-06-12 16:33:34 +01:00
parent c0e91efdb3
commit cd2a4bc510

View File

@@ -883,8 +883,7 @@ BOOST_AUTO_TEST_CASE(test_ToIntegralHex)
BOOST_CHECK_EQUAL(*n, 0);
n = ToIntegral<uint64_t>("FfFfFfFfFfFfFfFf", 16);
BOOST_CHECK_EQUAL(*n, 0xFfFfFfFfFfFfFfFfULL);
n = ToIntegral<int64_t>("-1", 16);
BOOST_CHECK_EQUAL(*n, -1);
BOOST_CHECK_EQUAL(*ToIntegral<int64_t>("-1", 16), -1);
// Invalid values
BOOST_CHECK(!ToIntegral<uint64_t>("", 16));
BOOST_CHECK(!ToIntegral<uint64_t>("-1", 16));