Bitcoin Core  22.99.0
P2P Digital Currency
parse_numbers.cpp
Go to the documentation of this file.
1 // Copyright (c) 2009-2020 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 
9 #include <string>
10 
11 FUZZ_TARGET(parse_numbers)
12 {
13  const std::string random_string(buffer.begin(), buffer.end());
14 
15  (void)ParseMoney(random_string);
16 
17  double d;
18  (void)ParseDouble(random_string, &d);
19 
20  uint8_t u8;
21  (void)ParseUInt8(random_string, &u8);
22 
23  uint16_t u16;
24  (void)ParseUInt16(random_string, &u16);
25 
26  int32_t i32;
27  (void)ParseInt32(random_string, &i32);
28  (void)atoi(random_string);
29 
30  uint32_t u32;
31  (void)ParseUInt32(random_string, &u32);
32 
33  int64_t i64;
34  (void)atoi64(random_string);
35  (void)ParseFixedPoint(random_string, 3, &i64);
36  (void)ParseInt64(random_string, &i64);
37 
38  uint64_t u64;
39  (void)ParseUInt64(random_string, &u64);
40 }
atoi64
int64_t atoi64(const std::string &str)
Definition: strencodings.cpp:440
ParseInt64
bool ParseInt64(const std::string &str, int64_t *out)
Convert string to signed 64-bit integer with strict parse error feedback.
Definition: strencodings.cpp:312
ParseFixedPoint
bool ParseFixedPoint(const std::string &val, int decimals, int64_t *amount_out)
Parse number as fixed point according to JSON number syntax.
Definition: strencodings.cpp:481
ParseDouble
bool ParseDouble(const std::string &str, double *out)
Convert string to double with strict parse error feedback.
Definition: strencodings.cpp:385
moneystr.h
atoi
int atoi(const std::string &str)
Definition: strencodings.cpp:449
ParseUInt16
bool ParseUInt16(const std::string &str, uint16_t *out)
Convert decimal string to unsigned 16-bit integer with strict parse error feedback.
Definition: strencodings.cpp:339
strencodings.h
ParseUInt64
bool ParseUInt64(const std::string &str, uint64_t *out)
Convert decimal string to unsigned 64-bit integer with strict parse error feedback.
Definition: strencodings.cpp:368
ParseInt32
bool ParseInt32(const std::string &str, int32_t *out)
Convert string to signed 32-bit integer with strict parse error feedback.
Definition: strencodings.cpp:296
fuzz.h
ParseMoney
std::optional< CAmount > ParseMoney(const std::string &money_string)
Parse an amount denoted in full coins.
Definition: moneystr.cpp:41
ParseUInt8
bool ParseUInt8(const std::string &str, uint8_t *out)
Convert decimal string to unsigned 8-bit integer with strict parse error feedback.
Definition: strencodings.cpp:327
ParseUInt32
bool ParseUInt32(const std::string &str, uint32_t *out)
Convert decimal string to unsigned 32-bit integer with strict parse error feedback.
Definition: strencodings.cpp:351
FUZZ_TARGET
FUZZ_TARGET(parse_numbers)
Definition: parse_numbers.cpp:11