2
2
#include < cstdlib>
3
3
#include < iostream>
4
4
#include < vector>
5
-
6
- // test that this option is ignored
7
- #define FASTFLOAT_ALLOWS_LEADING_PLUS
8
-
9
5
#include " fast_float/fast_float.h"
10
6
11
7
int main_readme () {
12
8
const std::string input = " +.1" ; // not valid
13
9
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
15
13
auto answer = fast_float::from_chars_advanced (
16
14
input.data (), input.data () + input.size (), result, options);
17
15
if (answer.ec == std::errc ()) {
@@ -24,7 +22,9 @@ int main_readme() {
24
22
int main_readme2 () {
25
23
const std::string input = " inf" ; // not valid in JSON
26
24
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
28
28
auto answer = fast_float::from_chars_advanced (
29
29
input.data (), input.data () + input.size (), result, options);
30
30
if (answer.ec == std::errc ()) {
@@ -38,7 +38,9 @@ int main_readme3() {
38
38
const std::string input =
39
39
" inf" ; // not valid in JSON but we allow it with json_or_infnan
40
40
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
42
44
auto answer = fast_float::from_chars_advanced (
43
45
input.data (), input.data () + input.size (), result, options);
44
46
if (answer.ec != std::errc () || (!std::isinf (result))) {
@@ -129,7 +131,9 @@ int main() {
129
131
const auto &expected_reason = reject[i].reason ;
130
132
auto answer = fast_float::parse_number_string (
131
133
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
133
137
if (answer.valid ) {
134
138
std::cerr << " json parse accepted invalid json " << f << std::endl;
135
139
return EXIT_FAILURE;
0 commit comments