mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-06 16:56:57 +08:00
compilation fix for internal tests
This commit is contained in:
parent
5ae2fba79d
commit
42131710b7
@ -10,7 +10,7 @@ int main_readme() {
|
|||||||
fast_float::parse_options options{
|
fast_float::parse_options options{
|
||||||
fast_float::chars_format::json |
|
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
|
||||||
auto answer = fast_float::from_chars_advanced(
|
auto const answer = fast_float::from_chars_advanced(
|
||||||
input.data(), input.data() + input.size(), result, options);
|
input.data(), input.data() + input.size(), result, options);
|
||||||
if (answer.ec == std::errc()) {
|
if (answer.ec == std::errc()) {
|
||||||
std::cerr << "should have failed\n";
|
std::cerr << "should have failed\n";
|
||||||
@ -25,7 +25,7 @@ int main_readme2() {
|
|||||||
fast_float::parse_options options{
|
fast_float::parse_options options{
|
||||||
fast_float::chars_format::json |
|
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
|
||||||
auto answer = fast_float::from_chars_advanced(
|
auto const answer = fast_float::from_chars_advanced(
|
||||||
input.data(), input.data() + input.size(), result, options);
|
input.data(), input.data() + input.size(), result, options);
|
||||||
if (answer.ec == std::errc()) {
|
if (answer.ec == std::errc()) {
|
||||||
std::cerr << "should have failed\n";
|
std::cerr << "should have failed\n";
|
||||||
@ -41,7 +41,7 @@ int main_readme3() {
|
|||||||
fast_float::parse_options options{
|
fast_float::parse_options options{
|
||||||
fast_float::chars_format::json_or_infnan |
|
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
|
||||||
auto answer = fast_float::from_chars_advanced(
|
auto const answer = fast_float::from_chars_advanced(
|
||||||
input.data(), input.data() + input.size(), result, options);
|
input.data(), input.data() + input.size(), result, options);
|
||||||
if (answer.ec != std::errc() || (!std::isinf(result))) {
|
if (answer.ec != std::errc() || (!std::isinf(result))) {
|
||||||
std::cerr << "should have parsed infinity\n";
|
std::cerr << "should have parsed infinity\n";
|
||||||
@ -97,7 +97,7 @@ int main() {
|
|||||||
auto const &s = accept[i].input;
|
auto const &s = accept[i].input;
|
||||||
auto const &expected = accept[i].expected;
|
auto const &expected = accept[i].expected;
|
||||||
double result;
|
double result;
|
||||||
auto answer =
|
auto const answer =
|
||||||
fast_float::from_chars(s.data(), s.data() + s.size(), result,
|
fast_float::from_chars(s.data(), s.data() + s.size(), result,
|
||||||
fast_float::chars_format::json_or_infnan);
|
fast_float::chars_format::json_or_infnan);
|
||||||
if (answer.ec != std::errc()) {
|
if (answer.ec != std::errc()) {
|
||||||
@ -120,7 +120,7 @@ int main() {
|
|||||||
for (std::size_t i = 0; i < reject.size(); ++i) {
|
for (std::size_t i = 0; i < reject.size(); ++i) {
|
||||||
auto const &s = reject[i].input;
|
auto const &s = reject[i].input;
|
||||||
double result;
|
double result;
|
||||||
auto answer = fast_float::from_chars(s.data(), s.data() + s.size(), result,
|
auto const answer = fast_float::from_chars(s.data(), s.data() + s.size(), result,
|
||||||
fast_float::chars_format::json);
|
fast_float::chars_format::json);
|
||||||
if (answer.ec == std::errc()) {
|
if (answer.ec == std::errc()) {
|
||||||
std::cerr << "json fmt accepted invalid json " << s << std::endl;
|
std::cerr << "json fmt accepted invalid json " << s << std::endl;
|
||||||
@ -131,13 +131,13 @@ int main() {
|
|||||||
for (std::size_t i = 0; i < reject.size(); ++i) {
|
for (std::size_t i = 0; i < reject.size(); ++i) {
|
||||||
auto const &f = reject[i].input;
|
auto const &f = reject[i].input;
|
||||||
auto const &expected_reason = reject[i].reason;
|
auto const &expected_reason = reject[i].reason;
|
||||||
auto answer = fast_float::parse_number_string<true>(
|
auto const answer = fast_float::parse_number_string<true>(
|
||||||
f.data(), f.data() + f.size(),
|
f.data(), f.data() + f.size(),
|
||||||
fast_float::parse_options(
|
fast_float::parse_options(
|
||||||
fast_float::chars_format::json |
|
fast_float::chars_format::json |
|
||||||
fast_float::chars_format::allow_leading_plus)); // should be
|
fast_float::chars_format::allow_leading_plus)); // should be
|
||||||
// ignored
|
// ignored
|
||||||
if (answer.valid) {
|
if (!answer.invalid) {
|
||||||
std::cerr << "json parse accepted invalid json " << f << std::endl;
|
std::cerr << "json parse accepted invalid json " << f << std::endl;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user