blob: 8e5e7dad11b364c8c31c12cb966a146e75139ca1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
// Copyright (c) 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/FuzzedDataProvider.h>
#include <test/fuzz/fuzz.h>
#include <util/spanparsing.h>
void test_one_input(const std::vector<uint8_t>& buffer)
{
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
const size_t query_size = fuzzed_data_provider.ConsumeIntegral<size_t>();
const std::string query = fuzzed_data_provider.ConsumeBytesAsString(std::min<size_t>(query_size, 1024 * 1024));
const std::string span_str = fuzzed_data_provider.ConsumeRemainingBytesAsString();
const Span<const char> const_span = MakeSpan(span_str);
Span<const char> mut_span = const_span;
(void)spanparsing::Const(query, mut_span);
mut_span = const_span;
(void)spanparsing::Func(query, mut_span);
mut_span = const_span;
(void)spanparsing::Expr(mut_span);
if (!query.empty()) {
mut_span = const_span;
(void)spanparsing::Split(mut_span, query.front());
}
}
|