Skip to content

Commit 43a428d

Browse files
committed
remove feature macro from tests
1 parent cd28b56 commit 43a428d

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

tests/fortran.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@
44
#include <cstdlib>
55
#include <iostream>
66
#include <vector>
7-
8-
#define FASTFLOAT_ALLOWS_LEADING_PLUS
9-
107
#include "fast_float/fast_float.h"
118

129
int main_readme() {
1310
const std::string input = "1d+4";
1411
double result;
15-
fast_float::parse_options options{fast_float::chars_format::fortran};
12+
fast_float::parse_options options{
13+
fast_float::chars_format::fortran |
14+
fast_float::chars_format::allow_leading_plus};
1615
auto answer = fast_float::from_chars_advanced(
1716
input.data(), input.data() + input.size(), result, options);
1817
if ((answer.ec != std::errc()) || ((result != 10000))) {
@@ -32,7 +31,9 @@ int main() {
3231
"1d-1", "1d-2", "1d-3", "1d-4"};
3332
const std::vector<std::string> fmt3{"+1+4", "+1+3", "+1+2", "+1+1", "+1+0",
3433
"+1-1", "+1-2", "+1-3", "+1-4"};
35-
const fast_float::parse_options options{fast_float::chars_format::fortran};
34+
const fast_float::parse_options options{
35+
fast_float::chars_format::fortran |
36+
fast_float::chars_format::allow_leading_plus};
3637

3738
for (auto const &f : fmt1) {
3839
auto d{std::distance(&fmt1[0], &f)};

tests/json_fmt.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
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

117
int 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() {
2422
int 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;

tests/rcppfastfloat_test.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
* See https://github.com/eddelbuettel/rcppfastfloat/issues/4
33
*/
44

5-
#define FASTFLOAT_ALLOWS_LEADING_PLUS 1
6-
#define FASTFLOAT_SKIP_WHITE_SPACE 1 // important !
75
#include "fast_float/fast_float.h"
86
#include <iostream>
97
#include <string>
@@ -61,7 +59,10 @@ bool eddelbuettel() {
6159
// answer contains a error code and a pointer to the end of the
6260
// parsed region (on success).
6361
auto const answer = fast_float::from_chars(
64-
input.data(), input.data() + input.size(), result);
62+
input.data(), input.data() + input.size(), result,
63+
fast_float::chars_format::general |
64+
fast_float::chars_format::allow_leading_plus |
65+
fast_float::chars_format::skip_white_space);
6566
if (answer.ec != std::errc()) {
6667
std::cout << "could not parse" << std::endl;
6768
if (expected_success) {

0 commit comments

Comments
 (0)