Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lemire committed Jan 28, 2024
1 parent 9be7de5 commit 7977ec6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
6 changes: 5 additions & 1 deletion fuzz/from_chars.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
21 changes: 20 additions & 1 deletion tests/fast_int.cpp
Original file line number Diff line number Diff line change
@@ -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 <cstdlib>
#include <iostream>
#include <vector>
Expand Down Expand Up @@ -744,6 +760,9 @@ int main() {
return EXIT_SUCCESS;
}
#else
#include <iostream>
#include <cstdlib>

int main() {
std::cerr << "The test requires C++17." << std::endl;
return EXIT_SUCCESS;
Expand Down

0 comments on commit 7977ec6

Please sign in to comment.