1 // Copyright (c) 2021, Paul Dreik
2 // For license information refer to format.h.
3 #include <fmt/chrono.h>
5 #include "fuzzer-common.h"
8 * a fuzzer for the chrono timepoints formatters
9 * C is a clock (std::chrono::system_clock etc)
11 template <typename C
> void doit(const uint8_t* data
, size_t size
) {
12 using Rep
= typename
C::time_point::rep
;
13 constexpr auto N
= sizeof(Rep
);
16 const auto x
= assign_from_buf
<Rep
>(data
);
17 typename
C::duration dur
{x
};
18 typename
C::time_point timepoint
{dur
};
21 data_to_string
format_str(data
, size
);
23 std::string message
= fmt::format(format_str
.get(), timepoint
);
26 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data
, size_t size
) {
28 doit
<std::chrono::system_clock
>(data
, size
);