mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-12 05:32:22 +02:00
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:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user