22#include < cstdlib>
33#include < iostream>
44#include < vector>
5-
6- // test that this option is ignored
7- #define FASTFLOAT_ALLOWS_LEADING_PLUS
8-
95#include " fast_float/fast_float.h"
106
117int main_readme () {
128 const std::string input = " +.1" ; // not valid
139 double result;
14- fast_float::parse_options options{fast_float::chars_format::json};
10+ fast_float::parse_options options{
11+ fast_float::chars_format::json |
12+ fast_float::chars_format::allow_leading_plus}; // should be ignored
1513 auto answer = fast_float::from_chars_advanced (
1614 input.data (), input.data () + input.size (), result, options);
1715 if (answer.ec == std::errc ()) {
@@ -24,7 +22,9 @@ int main_readme() {
2422int main_readme2 () {
2523 const std::string input = " inf" ; // not valid in JSON
2624 double result;
27- fast_float::parse_options options{fast_float::chars_format::json};
25+ fast_float::parse_options options{
26+ fast_float::chars_format::json |
27+ fast_float::chars_format::allow_leading_plus}; // should be ignored
2828 auto answer = fast_float::from_chars_advanced (
2929 input.data (), input.data () + input.size (), result, options);
3030 if (answer.ec == std::errc ()) {
@@ -38,7 +38,9 @@ int main_readme3() {
3838 const std::string input =
3939 " inf" ; // not valid in JSON but we allow it with json_or_infnan
4040 double result;
41- fast_float::parse_options options{fast_float::chars_format::json_or_infnan};
41+ fast_float::parse_options options{
42+ fast_float::chars_format::json_or_infnan |
43+ fast_float::chars_format::allow_leading_plus}; // should be ignored
4244 auto answer = fast_float::from_chars_advanced (
4345 input.data (), input.data () + input.size (), result, options);
4446 if (answer.ec != std::errc () || (!std::isinf (result))) {
@@ -129,7 +131,9 @@ int main() {
129131 const auto &expected_reason = reject[i].reason ;
130132 auto answer = fast_float::parse_number_string (
131133 f.data (), f.data () + f.size (),
132- fast_float::parse_options (fast_float::chars_format::json));
134+ fast_float::parse_options (
135+ fast_float::chars_format::json |
136+ fast_float::chars_format::allow_leading_plus)); // should be ignored
133137 if (answer.valid ) {
134138 std::cerr << " json parse accepted invalid json " << f << std::endl;
135139 return EXIT_FAILURE;
0 commit comments