This commit is contained in:
IRainman 2025-12-29 23:49:30 +03:00
parent f92d7fb594
commit 24231804ec
3 changed files with 14 additions and 16 deletions

View File

@ -661,7 +661,7 @@ int main() {
auto const &f = invalid_base_test_1[i];
int result;
auto answer =
fast_float::from_chars(f.data(), f.data() + f.size(), result, 1);
fast_float::from_chars(f.data(), f.data() + f.size(), result, -1);
if (answer.ec != std::errc::invalid_argument) {
std::cerr << "expected error should be 'invalid_argument' for: \"" << f
<< "\"" << std::endl;
@ -762,7 +762,7 @@ int main() {
auto const &f = int_out_of_range_base_test[i];
int64_t result;
auto answer = fast_float::from_chars(f.data(), f.data() + f.size(), result,
uint_fast8_t(2 + (i / 2)));
int(2 + (i / 2)));
if (answer.ec != std::errc::result_out_of_range) {
std::cerr << "expected error for should be 'result_out_of_range': \"" << f
<< "\"" << std::endl;
@ -807,7 +807,7 @@ int main() {
"7ORP63SH4DPHI",
"5G24A25TWKWFG",
"3W5E11264SGSG"};
uint_fast8_t base_unsigned = 2;
int base_unsigned = 2;
for (std::size_t i = 0; i < unsigned_out_of_range_base_test.size(); ++i) {
auto const &f = unsigned_out_of_range_base_test[i];
uint64_t result;
@ -898,7 +898,7 @@ int main() {
auto const &f = int_within_range_base_test[i];
int64_t result;
auto answer = fast_float::from_chars(f.data(), f.data() + f.size(), result,
uint_fast8_t(2 + (i / 2)));
int(2 + (i / 2)));
if (answer.ec != std::errc()) {
std::cerr << "converting " << f
<< " to int failed (most likely out of range)" << std::endl;
@ -943,7 +943,7 @@ int main() {
"7ORP63SH4DPHH",
"5G24A25TWKWFF",
"3W5E11264SGSF"};
uint_fast8_t base_unsigned2 = 2;
int base_unsigned2 = 2;
for (std::size_t i = 0; i < unsigned_within_range_base_test.size(); ++i) {
auto const &f = unsigned_within_range_base_test[i];
uint64_t result;
@ -1001,7 +1001,7 @@ int main() {
auto const &f = int_leading_zeros_test[i];
int result;
auto answer = fast_float::from_chars(f.data(), f.data() + f.size(), result,
uint_fast8_t(i + 2));
int(i + 2));
if (answer.ec != std::errc()) {
std::cerr << "could not convert to int for input: \"" << f << "\""
<< std::endl;

View File

@ -31,7 +31,6 @@ int main() {
"1d-1", "1d-2", "1d-3", "1d-4"};
std::vector<std::string> const fmt3{"+1+4", "+1+3", "+1+2", "+1+1", "+1+0",
"+1-1", "+1-2", "+1-3", "+1-4"};
fast_float::parse_options const options{
fast_float::chars_format::fortran |
fast_float::chars_format::allow_leading_plus};

View File

@ -10,7 +10,7 @@ int main_readme() {
fast_float::parse_options options{
fast_float::chars_format::json |
fast_float::chars_format::allow_leading_plus}; // should be ignored
auto const answer = fast_float::from_chars_advanced(
auto answer = fast_float::from_chars_advanced(
input.data(), input.data() + input.size(), result, options);
if (answer.ec == std::errc()) {
std::cerr << "should have failed\n";
@ -25,7 +25,7 @@ int main_readme2() {
fast_float::parse_options options{
fast_float::chars_format::json |
fast_float::chars_format::allow_leading_plus}; // should be ignored
auto const answer = fast_float::from_chars_advanced(
auto answer = fast_float::from_chars_advanced(
input.data(), input.data() + input.size(), result, options);
if (answer.ec == std::errc()) {
std::cerr << "should have failed\n";
@ -41,7 +41,7 @@ int main_readme3() {
fast_float::parse_options options{
fast_float::chars_format::json_or_infnan |
fast_float::chars_format::allow_leading_plus}; // should be ignored
auto const answer = fast_float::from_chars_advanced(
auto answer = fast_float::from_chars_advanced(
input.data(), input.data() + input.size(), result, options);
if (answer.ec != std::errc() || (!std::isinf(result))) {
std::cerr << "should have parsed infinity\n";
@ -97,7 +97,7 @@ int main() {
auto const &s = accept[i].input;
auto const &expected = accept[i].expected;
double result;
auto const answer =
auto answer =
fast_float::from_chars(s.data(), s.data() + s.size(), result,
fast_float::chars_format::json_or_infnan);
if (answer.ec != std::errc()) {
@ -120,8 +120,8 @@ int main() {
for (std::size_t i = 0; i < reject.size(); ++i) {
auto const &s = reject[i].input;
double result;
auto const answer = fast_float::from_chars(
s.data(), s.data() + s.size(), result, fast_float::chars_format::json);
auto answer = fast_float::from_chars(s.data(), s.data() + s.size(), result,
fast_float::chars_format::json);
if (answer.ec == std::errc()) {
std::cerr << "json fmt accepted invalid json " << s << std::endl;
return EXIT_FAILURE;
@ -131,12 +131,11 @@ int main() {
for (std::size_t i = 0; i < reject.size(); ++i) {
auto const &f = reject[i].input;
auto const &expected_reason = reject[i].reason;
auto const answer = fast_float::parse_number_string<true>(
auto answer = fast_float::parse_number_string<true>(
f.data(), f.data() + f.size(),
fast_float::parse_options(
fast_float::chars_format::json |
fast_float::chars_format::allow_leading_plus)); // should be
// ignored
fast_float::chars_format::allow_leading_plus)); // should be ignored
if (!answer.invalid) {
std::cerr << "json parse accepted invalid json " << f << std::endl;
return EXIT_FAILURE;