aboutsummaryrefslogtreecommitdiff
path: root/src/test/fuzz/parse_numbers.cpp
diff options
context:
space:
mode:
authorpracticalswift <practicalswift@users.noreply.github.com>2019-10-02 12:01:52 +0000
committerpracticalswift <practicalswift@users.noreply.github.com>2019-12-10 16:39:40 +0000
commite3d2bcf5cf7a53e5ca671cfed1fe7b6cf0c191ba (patch)
tree5cc0081820bbd5b451486131b80769576054d79d /src/test/fuzz/parse_numbers.cpp
parentfb8c12093aa37f5536a1a4ba341ee8bab4dabe60 (diff)
tests: Add fuzzing harnesses for various number parsing functions
Diffstat (limited to 'src/test/fuzz/parse_numbers.cpp')
-rw-r--r--src/test/fuzz/parse_numbers.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/test/fuzz/parse_numbers.cpp b/src/test/fuzz/parse_numbers.cpp
new file mode 100644
index 0000000000..59f89dc9fb
--- /dev/null
+++ b/src/test/fuzz/parse_numbers.cpp
@@ -0,0 +1,35 @@
+// Copyright (c) 2009-2019 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 <test/fuzz/fuzz.h>
+#include <util/moneystr.h>
+#include <util/strencodings.h>
+
+#include <string>
+
+void test_one_input(const std::vector<uint8_t>& buffer)
+{
+ const std::string random_string(buffer.begin(), buffer.end());
+
+ CAmount amount;
+ (void)ParseMoney(random_string, amount);
+
+ double d;
+ (void)ParseDouble(random_string, &d);
+
+ int32_t i32;
+ (void)ParseInt32(random_string, &i32);
+ (void)atoi(random_string);
+
+ uint32_t u32;
+ (void)ParseUInt32(random_string, &u32);
+
+ int64_t i64;
+ (void)atoi64(random_string);
+ (void)ParseFixedPoint(random_string, 3, &i64);
+ (void)ParseInt64(random_string, &i64);
+
+ uint64_t u64;
+ (void)ParseUInt64(random_string, &u64);
+}