mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-06 16:56:57 +08:00
Tests are updated.
This commit is contained in:
parent
2db26df2b8
commit
1ab438cf7a
@ -644,19 +644,20 @@ TEST_CASE("check_behavior") {
|
|||||||
|
|
||||||
TEST_CASE("decimal_point_parsing") {
|
TEST_CASE("decimal_point_parsing") {
|
||||||
double result;
|
double result;
|
||||||
fast_float::parse_options options{};
|
|
||||||
{
|
{
|
||||||
std::string const input = "1,25";
|
std::string const input = "1,25";
|
||||||
auto answer = fast_float::from_chars_advanced(
|
auto answer = fast_float::from_chars_advanced(
|
||||||
input.data(), input.data() + input.size(), result, options);
|
input.data(), input.data() + input.size(), result,
|
||||||
|
fast_float::parse_options{});
|
||||||
CHECK_MESSAGE(answer.ec == std::errc(), "expected parse success");
|
CHECK_MESSAGE(answer.ec == std::errc(), "expected parse success");
|
||||||
CHECK_MESSAGE(answer.ptr == input.data() + 1,
|
CHECK_MESSAGE(answer.ptr == input.data() + 1,
|
||||||
"Parsing should have stopped at comma");
|
"Parsing should have stopped at comma");
|
||||||
CHECK_EQ(result, 1.0);
|
CHECK_EQ(result, 1.0);
|
||||||
|
|
||||||
options.decimal_point = ',';
|
|
||||||
answer = fast_float::from_chars_advanced(
|
answer = fast_float::from_chars_advanced(
|
||||||
input.data(), input.data() + input.size(), result, options);
|
input.data(), input.data() + input.size(), result,
|
||||||
|
fast_float::parse_options(fast_float::chars_format::general, ',', 10)
|
||||||
|
);
|
||||||
CHECK_MESSAGE(answer.ec == std::errc(), "expected parse success");
|
CHECK_MESSAGE(answer.ec == std::errc(), "expected parse success");
|
||||||
CHECK_MESSAGE(answer.ptr == input.data() + input.size(),
|
CHECK_MESSAGE(answer.ptr == input.data() + input.size(),
|
||||||
"Parsing should have stopped at end");
|
"Parsing should have stopped at end");
|
||||||
@ -665,15 +666,18 @@ TEST_CASE("decimal_point_parsing") {
|
|||||||
{
|
{
|
||||||
std::string const input = "1.25";
|
std::string const input = "1.25";
|
||||||
auto answer = fast_float::from_chars_advanced(
|
auto answer = fast_float::from_chars_advanced(
|
||||||
input.data(), input.data() + input.size(), result, options);
|
input.data(), input.data() + input.size(), result,
|
||||||
|
fast_float::parse_options(fast_float::chars_format::general, ',', 10)
|
||||||
|
);
|
||||||
CHECK_MESSAGE(answer.ec == std::errc(), "expected parse success");
|
CHECK_MESSAGE(answer.ec == std::errc(), "expected parse success");
|
||||||
CHECK_MESSAGE(answer.ptr == input.data() + 1,
|
CHECK_MESSAGE(answer.ptr == input.data() + 1,
|
||||||
"Parsing should have stopped at dot");
|
"Parsing should have stopped at dot");
|
||||||
CHECK_EQ(result, 1.0);
|
CHECK_EQ(result, 1.0);
|
||||||
|
|
||||||
options.decimal_point = '.';
|
|
||||||
answer = fast_float::from_chars_advanced(
|
answer = fast_float::from_chars_advanced(
|
||||||
input.data(), input.data() + input.size(), result, options);
|
input.data(), input.data() + input.size(), result,
|
||||||
|
fast_float::parse_options{}
|
||||||
|
);
|
||||||
CHECK_MESSAGE(answer.ec == std::errc(), "expected parse success");
|
CHECK_MESSAGE(answer.ec == std::errc(), "expected parse success");
|
||||||
CHECK_MESSAGE(answer.ptr == input.data() + input.size(),
|
CHECK_MESSAGE(answer.ptr == input.data() + input.size(),
|
||||||
"Parsing should have stopped at end");
|
"Parsing should have stopped at end");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user