From 24231804ec0a8b9f6a4dd380ba71e558709c8724 Mon Sep 17 00:00:00 2001 From: IRainman Date: Mon, 29 Dec 2025 23:49:30 +0300 Subject: [PATCH] cleanup --- tests/fast_int.cpp | 12 ++++++------ tests/fortran.cpp | 1 - tests/json_fmt.cpp | 17 ++++++++--------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/tests/fast_int.cpp b/tests/fast_int.cpp index 0f06821..94e76fd 100644 --- a/tests/fast_int.cpp +++ b/tests/fast_int.cpp @@ -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; diff --git a/tests/fortran.cpp b/tests/fortran.cpp index 3847354..9167593 100644 --- a/tests/fortran.cpp +++ b/tests/fortran.cpp @@ -31,7 +31,6 @@ int main() { "1d-1", "1d-2", "1d-3", "1d-4"}; std::vector 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}; diff --git a/tests/json_fmt.cpp b/tests/json_fmt.cpp index ca4b46b..aa9da9c 100644 --- a/tests/json_fmt.cpp +++ b/tests/json_fmt.cpp @@ -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( + auto answer = fast_float::parse_number_string( 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;