// Copyright (c) 2009-2021 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include #include #include #include #include #include #include #include FUZZ_TARGET(parse_numbers) { const std::string random_string(buffer.begin(), buffer.end()); { const auto i8{ToIntegral(random_string)}; const auto u8{ToIntegral(random_string)}; const auto i16{ToIntegral(random_string)}; const auto u16{ToIntegral(random_string)}; const auto i32{ToIntegral(random_string)}; const auto u32{ToIntegral(random_string)}; const auto i64{ToIntegral(random_string)}; const auto u64{ToIntegral(random_string)}; // Dont check any values, just that each success result must fit into // the one with the largest bit-width. if (i8) { assert(i8 == i64); } if (u8) { assert(u8 == u64); } if (i16) { assert(i16 == i64); } if (u16) { assert(u16 == u64); } if (i32) { assert(i32 == i64); } if (u32) { assert(u32 == u64); } constexpr auto digits{"0123456789"}; if (i64) { assert(util::RemovePrefixView(random_string, "-").find_first_not_of(digits) == std::string::npos); } if (u64) { assert(random_string.find_first_not_of(digits) == std::string::npos); } } (void)ParseMoney(random_string); (void)LocaleIndependentAtoi(random_string); int64_t i64; (void)LocaleIndependentAtoi(random_string); (void)ParseFixedPoint(random_string, 3, &i64); }