44#include < system_error>
55
66fast_float::chars_format arbitrary_format (FuzzedDataProvider &fdp) {
7- using fast_float::chars_format;
8- switch (fdp.ConsumeIntegralInRange <int >(0 ,3 )) {
9- case 0 :
10- return chars_format::scientific;
11- break ;
12- case 1 :
13- return chars_format::fixed;
14- break ;
15- case 2 :
16- return chars_format::fixed;
17- break ;
18- }
19- return chars_format::general;
7+ using fast_float::chars_format;
8+ switch (fdp.ConsumeIntegralInRange <int >(0 , 3 )) {
9+ case 0 :
10+ return chars_format::scientific;
11+ break ;
12+ case 1 :
13+ return chars_format::fixed;
14+ break ;
15+ case 2 :
16+ return chars_format::fixed;
17+ break ;
18+ }
19+ return chars_format::general;
2020}
2121
2222extern " C" int LLVMFuzzerTestOneInput (const uint8_t *data, size_t size) {
2323 FuzzedDataProvider fdp (data, size);
2424 fast_float::chars_format format = arbitrary_format (fdp);
2525 double result_d = 0.0 ;
2626 std::string input_d = fdp.ConsumeRandomLengthString (128 );
27- auto answer =
28- fast_float::from_chars ( input_d.data (), input_d.data () + input_d.size (), result_d, format);
27+ auto answer = fast_float::from_chars (
28+ input_d.data (), input_d.data () + input_d.size (), result_d, format);
2929 std::string input_f = fdp.ConsumeRandomLengthString (128 );
3030 float result_f = 0.0 ;
31- answer =
32- fast_float::from_chars ( input_f.data (), input_f.data () + input_f.size (), result_f, format);
31+ answer = fast_float::from_chars (
32+ input_f.data (), input_f.data () + input_f.size (), result_f, format);
3333 int result_i = 0 ;
3434 std::string input_i = fdp.ConsumeRandomLengthString (128 );
35- answer =
36- fast_float::from_chars (input_i. data (), input_i.data () + input_i.size (), result_i);
35+ answer = fast_float::from_chars (input_i. data (),
36+ input_i.data () + input_i.size (), result_i);
3737 return 0 ;
3838}
0 commit comments