mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-07 01:06:48 +08:00
trying to fix tests.
This commit is contained in:
parent
8e1fda5d08
commit
6cacae0782
@ -656,7 +656,7 @@ TEST_CASE("decimal_point_parsing") {
|
||||
|
||||
answer = fast_float::from_chars_advanced(
|
||||
input.data(), input.data() + input.size(), result,
|
||||
fast_float::parse_options(fast_float::chars_format::general, ',', 10));
|
||||
fast_float::parse_options({fast_float::chars_format::general, ',', 10}));
|
||||
CHECK_MESSAGE(answer.ec == std::errc(), "expected parse success");
|
||||
CHECK_MESSAGE(answer.ptr == input.data() + input.size(),
|
||||
"Parsing should have stopped at end");
|
||||
@ -666,7 +666,8 @@ TEST_CASE("decimal_point_parsing") {
|
||||
std::string const input = "1.25";
|
||||
auto answer = fast_float::from_chars_advanced(
|
||||
input.data(), input.data() + input.size(), result,
|
||||
fast_float::parse_options(fast_float::chars_format::general, ',', 10));
|
||||
fast_float::parse_options({fast_float::chars_format::general, ',',
|
||||
10}));
|
||||
CHECK_MESSAGE(answer.ec == std::errc(), "expected parse success");
|
||||
CHECK_MESSAGE(answer.ptr == input.data() + 1,
|
||||
"Parsing should have stopped at dot");
|
||||
@ -1323,8 +1324,8 @@ TEST_CASE("double.general") {
|
||||
|
||||
TEST_CASE("double.decimal_point") {
|
||||
constexpr auto options = [] {
|
||||
return fast_float::parse_options(fast_float::chars_format::general, ',',
|
||||
10);
|
||||
return fast_float::parse_options({fast_float::chars_format::general, ',',
|
||||
10});
|
||||
}();
|
||||
|
||||
// infinities
|
||||
@ -1641,8 +1642,8 @@ TEST_CASE("float.general") {
|
||||
|
||||
TEST_CASE("float.decimal_point") {
|
||||
constexpr auto options = [] {
|
||||
return fast_float::parse_options(fast_float::chars_format::general, ',',
|
||||
10);
|
||||
return fast_float::parse_options({fast_float::chars_format::general, ',',
|
||||
10});
|
||||
}();
|
||||
|
||||
// infinity
|
||||
|
||||
@ -9,7 +9,7 @@ int main() {
|
||||
double result;
|
||||
auto answer = fast_float::from_chars_advanced(
|
||||
input.data(), input.data() + input.size(), result,
|
||||
fast_float::parse_options{fast_float::chars_format::general, ','});
|
||||
fast_float::parse_options({fast_float::chars_format::general, ','}));
|
||||
if ((answer.ec != std::errc()) || ((result != 3.1416))) {
|
||||
std::cerr << "parsing failure\n";
|
||||
return EXIT_FAILURE;
|
||||
|
||||
@ -11,9 +11,9 @@ int main_readme() {
|
||||
double result;
|
||||
auto answer = fast_float::from_chars_advanced(
|
||||
input.data(), input.data() + input.size(), result,
|
||||
fast_float::parse_options {
|
||||
fast_float::parse_options ({
|
||||
fast_float::chars_format::fortran |
|
||||
fast_float::chars_format::allow_leading_plus});
|
||||
fast_float::chars_format::allow_leading_plus}));
|
||||
if ((answer.ec != std::errc()) || ((result != 10000))) {
|
||||
std::cerr << "parsing failure\n" << result << "\n";
|
||||
return EXIT_FAILURE;
|
||||
@ -37,9 +37,9 @@ int main() {
|
||||
double result;
|
||||
auto answer{fast_float::from_chars_advanced(f.data(), f.data() + f.size(),
|
||||
result,
|
||||
fast_float::parse_options {
|
||||
fast_float::parse_options ({
|
||||
fast_float::chars_format::fortran |
|
||||
fast_float::chars_format::allow_leading_plus})};
|
||||
fast_float::chars_format::allow_leading_plus}))};
|
||||
if (answer.ec != std::errc() || result != expected[std::size_t(d)]) {
|
||||
std::cerr << "parsing failure on " << f << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
@ -51,9 +51,9 @@ int main() {
|
||||
double result;
|
||||
auto answer{fast_float::from_chars_advanced(f.data(), f.data() + f.size(),
|
||||
result,
|
||||
fast_float::parse_options {
|
||||
fast_float::parse_options ({
|
||||
fast_float::chars_format::fortran |
|
||||
fast_float::chars_format::allow_leading_plus})};
|
||||
fast_float::chars_format::allow_leading_plus}))};
|
||||
if (answer.ec != std::errc() || result != expected[std::size_t(d)]) {
|
||||
std::cerr << "parsing failure on " << f << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
@ -65,9 +65,9 @@ int main() {
|
||||
double result;
|
||||
auto answer{fast_float::from_chars_advanced(f.data(), f.data() + f.size(),
|
||||
result,
|
||||
fast_float::parse_options {
|
||||
fast_float::parse_options ({
|
||||
fast_float::chars_format::fortran |
|
||||
fast_float::chars_format::allow_leading_plus})};
|
||||
fast_float::chars_format::allow_leading_plus}))};
|
||||
if (answer.ec != std::errc() || result != expected[std::size_t(d)]) {
|
||||
std::cerr << "parsing failure on " << f << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
|
||||
@ -9,9 +9,9 @@ int main_readme() {
|
||||
double result;
|
||||
auto answer = fast_float::from_chars_advanced(
|
||||
input.data(), input.data() + input.size(), result,
|
||||
fast_float::parse_options options{
|
||||
fast_float::parse_options 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.ec == std::errc()) {
|
||||
std::cerr << "should have failed\n";
|
||||
@ -25,9 +25,9 @@ int main_readme2() {
|
||||
double result;
|
||||
auto answer = fast_float::from_chars_advanced(
|
||||
input.data(), input.data() + input.size(), result,
|
||||
fast_float::parse_options options{
|
||||
fast_float::parse_options 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.ec == std::errc()) {
|
||||
std::cerr << "should have failed\n";
|
||||
@ -42,9 +42,9 @@ int main_readme3() {
|
||||
double result;
|
||||
auto answer = fast_float::from_chars_advanced(
|
||||
input.data(), input.data() + input.size(), result,
|
||||
fast_float::parse_options options{
|
||||
fast_float::parse_options options({
|
||||
fast_float::chars_format::json_or_infnan |
|
||||
fast_float::chars_format::allow_leading_plus}; // should be ignored
|
||||
fast_float::chars_format::allow_leading_plus}); // should be ignored
|
||||
);
|
||||
if (answer.ec != std::errc() || (!std::isinf(result))) {
|
||||
std::cerr << "should have parsed infinity\n";
|
||||
@ -136,9 +136,9 @@ int main() {
|
||||
auto const &expected_reason = reject[i].reason;
|
||||
auto answer = fast_float::parse_number_string<true>(
|
||||
f.data(), f.data() + f.size(),
|
||||
fast_float::parse_options(
|
||||
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.valid) {
|
||||
std::cerr << "json parse accepted invalid json " << f << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user