Repository: bitcoin/bitcoin
File: src/test/fuzz/integer.cpp (C++)

Code before:
    }
    (void)MillisToTimeval(i64);
    (void)SighashToStr(uch);
    (void)SipHashUint256(u64, u64, u256);
    (void)SipHashUint256Extra(u64, u64, u256, u32);
    (void)ToLower(ch);
    (void)ToUpper(ch);
    {
        if (std::optional<CAmount> parsed = ParseMoney(ValueFromAmount(i64).getValStr())) {
            assert(parsed.value() == i64);
        }
    }
    if (i32 >= 0 && i32 <= 16) {
        assert(i32 == CScript::DecodeOP_N(CScript::EncodeOP_N(i32)));
    }

    const std::chrono::seconds seconds{i64};
    assert(count_seconds(seconds) == i64);

    const CScriptNum script_num{i64};
    (void)script_num.getint();
    (void)script_num.getvch();

    const arith_uint256 au256 = UintToArith256(u256);
    assert(ArithToUint256(au256) == u256);
    assert(uint256S(au256.GetHex()) == u256);
    (void)au256.bits();
    (void)au256.GetCompact(/* fNegative= */ false);
    (void)au256.GetCompact(/* fNegative= */ true);
    (void)au256.getdouble();
    (void)au256.GetHex();
    (void)au256.GetLow64();
    (void)au256.size();
    (void)au256.ToString();

    const CKeyID key_id{u160};
    const CScriptID script_id{u160};

    {
        DataStream stream{};

        uint256 deserialized_u256;
        stream << u256;
        stream >> deserialized_u256;
        assert(u256 == deserialized_u256 && stream.empty());

        uint160 deserialized_u160;
        stream << u160;
        stream >> deserialized_u160;
        assert(u160 == deserialized_u160 && stream.empty());


Review comment (suggestion):
nit1: you might as well delete the empty `(void)au256.GetHex();` a few lines below
nit2: `value()` is redundant here (i.e. `assert(uint256::FromHex(au256.GetHex()) == u256);` suffices) since `std::optional` has an `==`:
```C++
operator==(const optional<_Tp>& __x, const _Up& __v)
{
    return static_cast<bool>(__x) ? *__x == __v : false;
}
```

Code after:
    }
    (void)MillisToTimeval(i64);
    (void)SighashToStr(uch);
    (void)SipHashUint256(u64, u64, u256);
    (void)SipHashUint256Extra(u64, u64, u256, u32);
    (void)ToLower(ch);
    (void)ToUpper(ch);
    {
        if (std::optional<CAmount> parsed = ParseMoney(ValueFromAmount(i64).getValStr())) {
            assert(parsed.value() == i64);
        }
    }
    if (i32 >= 0 && i32 <= 16) {
        assert(i32 == CScript::DecodeOP_N(CScript::EncodeOP_N(i32)));
    }

    const std::chrono::seconds seconds{i64};
    assert(count_seconds(seconds) == i64);

    const CScriptNum script_num{i64};
    (void)script_num.getint();
    (void)script_num.getvch();

    const arith_uint256 au256 = UintToArith256(u256);
    assert(ArithToUint256(au256) == u256);
    assert(uint256::FromHex(au256.GetHex()).value() == u256);
    (void)au256.bits();
    (void)au256.GetCompact(/* fNegative= */ false);
    (void)au256.GetCompact(/* fNegative= */ true);
    (void)au256.getdouble();
    (void)au256.GetHex();
    (void)au256.GetLow64();
    (void)au256.size();
    (void)au256.ToString();

    const CKeyID key_id{u160};
    const CScriptID script_id{u160};

    {
        DataStream stream{};

        uint256 deserialized_u256;
        stream << u256;
        stream >> deserialized_u256;
        assert(u256 == deserialized_u256 && stream.empty());

        uint160 deserialized_u160;
        stream << u160;
        stream >> deserialized_u160;
        assert(u160 == deserialized_u160 && stream.empty());