diff --git a/fuzz/from_chars.cc b/fuzz/from_chars.cc index 4517d4a0..f47466f1 100644 --- a/fuzz/from_chars.cc +++ b/fuzz/from_chars.cc @@ -27,8 +27,12 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { auto answer = fast_float::from_chars(input_d.data(), input_d.data() + input_d.size(), result_d, format); std::string input_f = fdp.ConsumeRandomLengthString(128); - double result_f = 0.0; + float result_f = 0.0; answer = fast_float::from_chars(input_f.data(), input_f.data() + input_f.size(), result_f, format); + int result_i = 0; + std::string input_i = fdp.ConsumeRandomLengthString(128); + answer = + fast_float::from_chars(input_i.data(), input_i.data() + input_i.size(), result_i); return 0; } \ No newline at end of file diff --git a/tests/fast_int.cpp b/tests/fast_int.cpp index 8ef7784a..e12deeac 100644 --- a/tests/fast_int.cpp +++ b/tests/fast_int.cpp @@ -1,4 +1,20 @@ -#if defined(__cplusplus) && (__cplusplus >= 201703L) +#ifndef __cplusplus +#error fastfloat requires a C++ compiler +#endif + +// We want to enable the tests only for C++17 and above. +#ifndef FASTFLOAT_CPLUSPLUS +#if defined(_MSVC_LANG) && !defined(__clang__) +#define FASTFLOAT_CPLUSPLUS (_MSC_VER == 1900 ? 201103L : _MSVC_LANG) +#else +#define FASTFLOAT_CPLUSPLUS __cplusplus +#endif +#endif + + +#if FASTFLOAT_CPLUSPLUS >= 201703L + + #include #include #include @@ -744,6 +760,9 @@ int main() { return EXIT_SUCCESS; } #else +#include +#include + int main() { std::cerr << "The test requires C++17." << std::endl; return EXIT_SUCCESS;