mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-06 16:56:57 +08:00
We need to update some of our exhaustive tests to the new API
This commit is contained in:
parent
843fb97064
commit
ca43e6722e
@ -30,7 +30,10 @@ void allvalues() {
|
||||
const char *string_end = to_string(v, buffer);
|
||||
float result_value;
|
||||
auto result = fast_float::from_chars(buffer, string_end, result_value);
|
||||
if (result.ec != std::errc()) {
|
||||
// Starting with version 4.0 for fast_float, we return result_out_of_range if the
|
||||
// value is either too small (too close to zero) or too large (effectively infinity).
|
||||
// So std::errc::result_out_of_range is normal for well-formed input strings.
|
||||
if (result.ec != std::errc() && result.ec != std::errc::result_out_of_range) {
|
||||
std::cerr << "parsing error ? " << buffer << std::endl;
|
||||
abort();
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ bool basic_test_64bit(std::string vals, double val) {
|
||||
double result_value;
|
||||
auto result = fast_float::from_chars(vals.data(), vals.data() + vals.size(),
|
||||
result_value);
|
||||
if (result.ec != std::errc()) {
|
||||
if (result.ec != std::errc() && result.ec != std::errc::result_out_of_range) {
|
||||
std::cerr << " I could not parse " << vals << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -90,7 +90,10 @@ bool allvalues() {
|
||||
|
||||
float result_value;
|
||||
auto result = fast_float::from_chars(buffer, string_end, result_value);
|
||||
if (result.ec != std::errc()) {
|
||||
// Starting with version 4.0 for fast_float, we return result_out_of_range if the
|
||||
// value is either too small (too close to zero) or too large (effectively infinity).
|
||||
// So std::errc::result_out_of_range is normal for well-formed input strings.
|
||||
if (result.ec != std::errc() && result.ec != std::errc::result_out_of_range) {
|
||||
std::cerr << "parsing error ? " << buffer << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -29,7 +29,10 @@ void allvalues() {
|
||||
const char *string_end = to_string(v, buffer);
|
||||
float result_value;
|
||||
auto result = fast_float::from_chars(buffer, string_end, result_value);
|
||||
if (result.ec != std::errc()) {
|
||||
// Starting with version 4.0 for fast_float, we return result_out_of_range if the
|
||||
// value is either too small (too close to zero) or too large (effectively infinity).
|
||||
// So std::errc::result_out_of_range is normal for well-formed input strings.
|
||||
if (result.ec != std::errc() && result.ec != std::errc::result_out_of_range) {
|
||||
std::cerr << "parsing error ? " << buffer << std::endl;
|
||||
abort();
|
||||
}
|
||||
|
||||
@ -28,7 +28,10 @@ void all_32bit_values() {
|
||||
const char *string_end = to_string(v, buffer);
|
||||
double result_value;
|
||||
auto result = fast_float::from_chars(buffer, string_end, result_value);
|
||||
if (result.ec != std::errc()) {
|
||||
// Starting with version 4.0 for fast_float, we return result_out_of_range if the
|
||||
// value is either too small (too close to zero) or too large (effectively infinity).
|
||||
// So std::errc::result_out_of_range is normal for well-formed input strings.
|
||||
if (result.ec != std::errc() && result.ec != std::errc::result_out_of_range) {
|
||||
std::cerr << "parsing error ? " << buffer << std::endl;
|
||||
abort();
|
||||
}
|
||||
|
||||
@ -56,7 +56,10 @@ void random_values(size_t N) {
|
||||
const char *string_end = to_string(v, buffer);
|
||||
double result_value;
|
||||
auto result = fast_float::from_chars(buffer, string_end, result_value);
|
||||
if (result.ec != std::errc()) {
|
||||
// Starting with version 4.0 for fast_float, we return result_out_of_range if the
|
||||
// value is either too small (too close to zero) or too large (effectively infinity).
|
||||
// So std::errc::result_out_of_range is normal for well-formed input strings.
|
||||
if (result.ec != std::errc() && result.ec != std::errc::result_out_of_range) {
|
||||
std::cerr << "parsing error ? " << buffer << std::endl;
|
||||
errors++;
|
||||
if (errors > 10) {
|
||||
|
||||
@ -22,7 +22,7 @@ bool test() {
|
||||
while((begin < end) && (std::isspace(*begin))) { begin++; }
|
||||
auto result = fast_float::from_chars(begin, end,
|
||||
result_value);
|
||||
if (result.ec != std::errc()) {
|
||||
if (result.ec != std::errc() && result.ec != std::errc::result_out_of_range) {
|
||||
printf("parsing %.*s\n", int(end - begin), begin);
|
||||
std::cerr << " I could not parse " << std::endl;
|
||||
return false;
|
||||
|
||||
@ -105,7 +105,7 @@ bool tester() {
|
||||
double result_value;
|
||||
auto result =
|
||||
fast_float::from_chars(to_be_parsed.data(), to_be_parsed.data() + to_be_parsed.size(), result_value);
|
||||
if (result.ec != std::errc()) {
|
||||
if (result.ec != std::errc() && result.ec != std::errc::result_out_of_range) {
|
||||
std::cout << to_be_parsed << std::endl;
|
||||
std::cerr << " I could not parse " << std::endl;
|
||||
return false;
|
||||
|
||||
@ -59,7 +59,10 @@ void random_values(size_t N) {
|
||||
const char *string_end = to_string(v, buffer);
|
||||
double result_value;
|
||||
auto result = fast_float::from_chars(buffer, string_end, result_value);
|
||||
if (result.ec != std::errc()) {
|
||||
// Starting with version 4.0 for fast_float, we return result_out_of_range if the
|
||||
// value is either too small (too close to zero) or too large (effectively infinity).
|
||||
// So std::errc::result_out_of_range is normal for well-formed input strings.
|
||||
if (result.ec != std::errc() && result.ec != std::errc::result_out_of_range) {
|
||||
std::cerr << "parsing error ? " << buffer << std::endl;
|
||||
errors++;
|
||||
if (errors > 10) {
|
||||
|
||||
@ -101,7 +101,12 @@ size_t build_random_string(RandomEngine &rand, char *buffer) {
|
||||
if (i == size_t(location_of_decimal_separator)) {
|
||||
buffer[pos++] = '.';
|
||||
}
|
||||
buffer[pos++] = char(rand.next_digit() + '0');
|
||||
buffer[pos] = char(rand.next_digit() + '0');
|
||||
// We can have a leading zero only if location_of_decimal_separator = 1.
|
||||
while(i == 0 && 1 != size_t(location_of_decimal_separator) && buffer[pos] == '0') {
|
||||
buffer[pos] = char(rand.next_digit() + '0');
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
if (rand.next_bool()) {
|
||||
if (rand.next_bool()) {
|
||||
@ -178,7 +183,7 @@ bool tester(uint64_t seed, size_t volume) {
|
||||
double result_value;
|
||||
auto result =
|
||||
fast_float::from_chars(buffer, buffer + length, result_value);
|
||||
if (result.ec != std::errc()) {
|
||||
if (result.ec != std::errc() && result.ec != std::errc::result_out_of_range) {
|
||||
printf("parsing %.*s\n", int(length), buffer);
|
||||
std::cerr << " I could not parse " << std::endl;
|
||||
return false;
|
||||
@ -201,7 +206,7 @@ bool tester(uint64_t seed, size_t volume) {
|
||||
float result_value;
|
||||
auto result =
|
||||
fast_float::from_chars(buffer, buffer + length, result_value);
|
||||
if (result.ec != std::errc()) {
|
||||
if (result.ec != std::errc() && result.ec != std::errc::result_out_of_range) {
|
||||
printf("parsing %.*s\n", int(length), buffer);
|
||||
std::cerr << " I could not parse " << std::endl;
|
||||
return false;
|
||||
|
||||
@ -97,7 +97,12 @@ size_t build_random_string(RandomEngine &rand, char *buffer) {
|
||||
if (i == size_t(location_of_decimal_separator)) {
|
||||
buffer[pos++] = '.';
|
||||
}
|
||||
buffer[pos++] = char(rand.next_digit() + '0');
|
||||
buffer[pos] = char(rand.next_digit() + '0');
|
||||
// We can have a leading zero only if location_of_decimal_separator = 1.
|
||||
while(i == 0 && 1 != size_t(location_of_decimal_separator) && buffer[pos] == '0') {
|
||||
buffer[pos] = char(rand.next_digit() + '0');
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
if (rand.next_bool()) {
|
||||
if (rand.next_bool()) {
|
||||
@ -174,7 +179,7 @@ bool tester(uint64_t seed, size_t volume) {
|
||||
double result_value;
|
||||
auto result =
|
||||
fast_float::from_chars(buffer, buffer + length, result_value);
|
||||
if (result.ec != std::errc()) {
|
||||
if (result.ec != std::errc() && result.ec != std::errc::result_out_of_range) {
|
||||
printf("parsing %.*s\n", int(length), buffer);
|
||||
std::cerr << " I could not parse " << std::endl;
|
||||
return false;
|
||||
@ -197,7 +202,7 @@ bool tester(uint64_t seed, size_t volume) {
|
||||
float result_value;
|
||||
auto result =
|
||||
fast_float::from_chars(buffer, buffer + length, result_value);
|
||||
if (result.ec != std::errc()) {
|
||||
if (result.ec != std::errc() && result.ec != std::errc::result_out_of_range) {
|
||||
printf("parsing %.*s\n", int(length), buffer);
|
||||
std::cerr << " I could not parse " << std::endl;
|
||||
return false;
|
||||
|
||||
@ -239,7 +239,7 @@ bool partow_test() {
|
||||
T result_value;
|
||||
auto result = fast_float::from_chars(st.data(), st.data() + st.size(),
|
||||
result_value);
|
||||
if (result.ec != std::errc()) {
|
||||
if (result.ec != std::errc() && result.ec != std::errc::result_out_of_range) {
|
||||
printf("parsing %.*s\n", int(st.size()), st.data());
|
||||
std::cerr << " I could not parse " << std::endl;
|
||||
return false;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user