Changeset View
Changeset View
Standalone View
Standalone View
src/test/fuzz/integer.cpp
Show First 20 Lines • Show All 135 Lines • ▼ Show 20 Lines | void test_one_input(const std::vector<uint8_t> &buffer) { | ||||
// std::numeric_limits<int64_t>::min() | // std::numeric_limits<int64_t>::min() | ||||
if (i64 != std::numeric_limits<int64_t>::min()) { | if (i64 != std::numeric_limits<int64_t>::min()) { | ||||
Amount parsed_money; | Amount parsed_money; | ||||
if (ParseMoney(ValueFromAmount(i64 * SATOSHI).getValStr(), | if (ParseMoney(ValueFromAmount(i64 * SATOSHI).getValStr(), | ||||
parsed_money)) { | parsed_money)) { | ||||
assert(parsed_money == i64 * SATOSHI); | assert(parsed_money == i64 * SATOSHI); | ||||
} | } | ||||
} | } | ||||
if (i32 >= 0 && i32 <= 16) { | |||||
assert(i32 == CScript::DecodeOP_N(CScript::EncodeOP_N(i32))); | |||||
} | |||||
const std::chrono::seconds seconds{i64}; | const std::chrono::seconds seconds{i64}; | ||||
assert(count_seconds(seconds) == i64); | assert(count_seconds(seconds) == i64); | ||||
const CScriptNum script_num{i64}; | |||||
(void)script_num.getint(); | |||||
// Avoid negation failure: | |||||
// script/script.h:332:35: runtime error: negation of -9223372036854775808 | |||||
// cannot be represented in type 'int64_t' (aka 'long'); cast to an unsigned | |||||
// type to negate this value to itself | |||||
if (script_num != CScriptNum{std::numeric_limits<int64_t>::min()}) { | |||||
(void)script_num.getvch(); | |||||
} | |||||
const arith_uint256 au256 = UintToArith256(u256); | const arith_uint256 au256 = UintToArith256(u256); | ||||
assert(ArithToUint256(au256) == u256); | assert(ArithToUint256(au256) == u256); | ||||
assert(uint256S(au256.GetHex()) == u256); | assert(uint256S(au256.GetHex()) == u256); | ||||
(void)au256.bits(); | (void)au256.bits(); | ||||
(void)au256.GetCompact(/* fNegative= */ false); | (void)au256.GetCompact(/* fNegative= */ false); | ||||
(void)au256.GetCompact(/* fNegative= */ true); | (void)au256.GetCompact(/* fNegative= */ true); | ||||
(void)au256.getdouble(); | (void)au256.getdouble(); | ||||
(void)au256.GetHex(); | (void)au256.GetHex(); | ||||
▲ Show 20 Lines • Show All 129 Lines • Show Last 20 Lines |