mirror of
https://github.com/fastfloat/fast_float.git
synced 2026-02-09 03:06:46 +08:00
Ignore FASTFLOAT_ALLOWS_LEADING_PLUS for JSON format
This commit is contained in:
parent
4de8d715e6
commit
2395482ad5
@ -280,7 +280,7 @@ parsed_number_string_t<UC> parse_number_string(UC const *p, UC const * pend, par
|
|||||||
answer.too_many_digits = false;
|
answer.too_many_digits = false;
|
||||||
answer.negative = (*p == UC('-'));
|
answer.negative = (*p == UC('-'));
|
||||||
#ifdef FASTFLOAT_ALLOWS_LEADING_PLUS // disabled by default
|
#ifdef FASTFLOAT_ALLOWS_LEADING_PLUS // disabled by default
|
||||||
if ((*p == UC('-')) || (*p == UC('+'))) {
|
if ((*p == UC('-')) || (fmt != chars_format::json && *p == UC('+'))) {
|
||||||
#else
|
#else
|
||||||
if (*p == UC('-')) { // C++17 20.19.3.(7.1) explicitly forbids '+' sign here
|
if (*p == UC('-')) { // C++17 20.19.3.(7.1) explicitly forbids '+' sign here
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -3,13 +3,16 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
// test that this option is ignored
|
||||||
|
#define FASTFLOAT_ALLOWS_LEADING_PLUS
|
||||||
|
|
||||||
#include "fast_float/fast_float.h"
|
#include "fast_float/fast_float.h"
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
const std::vector<double> expected{ -0.2, 0.02, 0.002, 1., 0. };
|
const std::vector<double> expected{ -0.2, 0.02, 0.002, 1., 0. };
|
||||||
const std::vector<std::string> accept{ "-0.2", "0.02", "0.002", "1e+0000", "0e-2" };
|
const std::vector<std::string> accept{ "-0.2", "0.02", "0.002", "1e+0000", "0e-2" };
|
||||||
const std::vector<std::string> reject{ "-.2", "00.02", "0.e+1", "00.e+1", ".25"};
|
const std::vector<std::string> reject{ "-.2", "00.02", "0.e+1", "00.e+1", ".25", "+0.25"};
|
||||||
const auto fmt = fast_float::chars_format::json;
|
const auto fmt = fast_float::chars_format::json;
|
||||||
|
|
||||||
for (std::size_t i = 0; i < accept.size(); ++i)
|
for (std::size_t i = 0; i < accept.size(); ++i)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user