Bitcoin Core 31.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
parse_numbers.cpp
Go to the documentation of this file.
1// Copyright (c) 2009-present The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#include <test/fuzz/fuzz.h>
6#include <util/moneystr.h>
7#include <util/strencodings.h>
8#include <util/string.h>
9
10#include <cassert>
11#include <cstdint>
12#include <optional>
13#include <string>
14
16{
17 const std::string random_string(buffer.begin(), buffer.end());
18 {
27 // Dont check any values, just that each success result must fit into
28 // the one with the largest bit-width.
29 if (i8) {
30 assert(i8 == i64);
31 }
32 if (u8) {
33 assert(u8 == u64);
34 }
35 if (i16) {
36 assert(i16 == i64);
37 }
38 if (u16) {
39 assert(u16 == u64);
40 }
41 if (i32) {
42 assert(i32 == i64);
43 }
44 if (u32) {
45 assert(u32 == u64);
46 }
47 constexpr auto digits{"0123456789"};
48 if (i64) {
50 }
51 if (u64) {
52 assert(random_string.find_first_not_of(digits) == std::string::npos);
53 }
54 }
55
57
59
63}
unsigned int u32
unsigned char u8
#define FUZZ_TARGET(...)
Definition fuzz.h:35
std::optional< CAmount > ParseMoney(const std::string &money_string)
Parse an amount denoted in full coins.
Definition moneystr.cpp:45
std::string_view RemovePrefixView(std::string_view str, std::string_view prefix)
Definition string.h:182
std::string random_string(uint32_t length)
bool ParseFixedPoint(std::string_view val, int decimals, int64_t *amount_out)
Parse number as fixed point according to JSON number syntax.
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
Definition time.h:73
assert(!tx.IsCoinBase())