Bitcoin Core 28.99.0
P2P Digital Currency
parse_iso8601.cpp
Go to the documentation of this file.
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
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
14FUZZ_TARGET(parse_iso8601)
15{
16 FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
17
18 const int64_t random_time = fuzzed_data_provider.ConsumeIntegral<int32_t>();
19 const std::string random_string = fuzzed_data_provider.ConsumeRemainingBytesAsString();
20
21 const std::string iso8601_datetime = FormatISO8601DateTime(random_time);
22 (void)FormatISO8601Date(random_time);
23 const int64_t parsed_time_1{ParseISO8601DateTime(iso8601_datetime).value()};
24 assert(parsed_time_1 == random_time);
25
26 (void)ParseISO8601DateTime(random_string);
27}
std::string ConsumeRemainingBytesAsString()
FUZZ_TARGET(parse_iso8601)
std::string FormatISO8601Date(int64_t nTime)
Definition: time.cpp:58
std::optional< int64_t > ParseISO8601DateTime(std::string_view str)
Definition: time.cpp:66
std::string FormatISO8601DateTime(int64_t nTime)
ISO 8601 formatting is preferred.
Definition: time.cpp:49
assert(!tx.IsCoinBase())