/root/bitcoin/src/test/fuzz/parse_iso8601.cpp
Line | Count | Source |
1 | | // Copyright (c) 2019-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/FuzzedDataProvider.h> |
6 | | #include <test/fuzz/fuzz.h> |
7 | | #include <util/time.h> |
8 | | |
9 | | #include <cassert> |
10 | | #include <cstdint> |
11 | | #include <string> |
12 | | #include <vector> |
13 | | |
14 | | FUZZ_TARGET(parse_iso8601) |
15 | 0 | { |
16 | 0 | FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size()); |
17 | |
|
18 | 0 | const int64_t random_time = fuzzed_data_provider.ConsumeIntegral<int32_t>(); |
19 | 0 | const std::string random_string = fuzzed_data_provider.ConsumeRemainingBytesAsString(); |
20 | |
|
21 | 0 | const std::string iso8601_datetime = FormatISO8601DateTime(random_time); |
22 | 0 | (void)FormatISO8601Date(random_time); |
23 | 0 | const int64_t parsed_time_1{ParseISO8601DateTime(iso8601_datetime).value()}; |
24 | 0 | assert(parsed_time_1 == random_time); |
25 | | |
26 | 0 | (void)ParseISO8601DateTime(random_string); |
27 | 0 | } |