Skip to content

Commit ca43e67

Browse files
committed
We need to update some of our exhaustive tests to the new API
1 parent 843fb97 commit ca43e67

21 files changed

+81
-53
lines changed

.github/workflows/ubuntu22-clang.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ jobs:
2222
cd build20 &&
2323
CXX=clang++-14 cmake -DFASTFLOAT_CONSTEXPR_TESTS=ON -DCMAKE_CXX_STANDARD=20 -DFASTFLOAT_TEST=ON .. &&
2424
cmake --build . &&
25-
ctest --output-on-failure
25+
ctest --output-on-failure

.github/workflows/ubuntu22-gcc12.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ jobs:
2020
cd build20 &&
2121
CXX=g++-12 CXXFLAGS=-Werror cmake -DFASTFLOAT_CONSTEXPR_TESTS=ON -DCMAKE_CXX_STANDARD=20 -DFASTFLOAT_TEST=ON .. &&
2222
cmake --build . &&
23-
ctest --output-on-failure
23+
ctest --output-on-failure

.github/workflows/ubuntu22.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ jobs:
1313
cd build &&
1414
cmake -DFASTFLOAT_TEST=ON .. &&
1515
cmake --build . &&
16-
ctest --output-on-failure
16+
ctest --output-on-failure

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,11 @@ It can parse random floating-point numbers at a speed of 1 GB/s on some systems.
189189
$ ./build/benchmarks/benchmark
190190
# parsing random integers in the range [0,1)
191191
volume = 2.09808 MB
192-
netlib : 271.18 MB/s (+/- 1.2 %) 12.93 Mfloat/s
193-
doubleconversion : 225.35 MB/s (+/- 1.2 %) 10.74 Mfloat/s
194-
strtod : 190.94 MB/s (+/- 1.6 %) 9.10 Mfloat/s
195-
abseil : 430.45 MB/s (+/- 2.2 %) 20.52 Mfloat/s
196-
fastfloat : 1042.38 MB/s (+/- 9.9 %) 49.68 Mfloat/s
192+
netlib : 271.18 MB/s (+/- 1.2 %) 12.93 Mfloat/s
193+
doubleconversion : 225.35 MB/s (+/- 1.2 %) 10.74 Mfloat/s
194+
strtod : 190.94 MB/s (+/- 1.6 %) 9.10 Mfloat/s
195+
abseil : 430.45 MB/s (+/- 2.2 %) 20.52 Mfloat/s
196+
fastfloat : 1042.38 MB/s (+/- 9.9 %) 49.68 Mfloat/s
197197
```
198198
199199
See https://github.com/lemire/simple_fastfloat_benchmark for our benchmarking code.

include/fast_float/decimal_to_binary.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ namespace detail {
4848
* where
4949
* p = log(5**q)/log(2) = q * log(5)/log(2)
5050
*
51-
* For negative values of q in (-400,0), we have that
51+
* For negative values of q in (-400,0), we have that
5252
* f = (((152170 + 65536) * q ) >> 16);
53-
* is equal to
53+
* is equal to
5454
* -ceil(p) + q
5555
* where
5656
* p = log(5**-q)/log(2) = -q * log(5)/log(2)

script/amalgamate.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
processed_files[filename] = text
3232

3333
# code
34-
for filename in [ 'constexpr_feature_detect.h', 'fast_float.h', 'float_common.h', 'ascii_number.h',
34+
for filename in [ 'constexpr_feature_detect.h', 'fast_float.h', 'float_common.h', 'ascii_number.h',
3535
'fast_table.h', 'decimal_to_binary.h', 'bigint.h',
3636
'ascii_number.h', 'digit_comparison.h', 'parse_number.h']:
3737
with open('include/fast_float/' + filename, encoding='utf8') as f:
@@ -73,10 +73,10 @@ def license_content(license_arg):
7373
return result
7474

7575
text = ''.join([
76-
processed_files['AUTHORS'], processed_files['CONTRIBUTORS'],
76+
processed_files['AUTHORS'], processed_files['CONTRIBUTORS'],
7777
*license_content(args.license),
7878
processed_files['constexpr_feature_detect.h'],
79-
processed_files['fast_float.h'], processed_files['float_common.h'],
79+
processed_files['fast_float.h'], processed_files['float_common.h'],
8080
processed_files['ascii_number.h'], processed_files['fast_table.h'],
8181
processed_files['decimal_to_binary.h'], processed_files['bigint.h'],
8282
processed_files['ascii_number.h'], processed_files['digit_comparison.h'],

script/mushtak_lemire.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#
2-
# Reference :
2+
# Reference :
33
# Noble Mushtak and Daniel Lemire, Fast Number Parsing Without Fallback (to appear)
44
#
55

66
all_tqs = []
77

88
# Generates all possible values of T[q]
9-
# Appendix B of Number parsing at a gigabyte per second.
9+
# Appendix B of Number parsing at a gigabyte per second.
1010
# Software: Practice and Experience 2021;51(8):1700–1727.
1111
for q in range(-342, -27):
1212
power5 = 5**-q
@@ -44,9 +44,9 @@ def continued_fraction(numer, denom):
4444
numer, denom = denom, rem
4545
return cf
4646

47-
# Given a continued fraction [a0; a1, a2, ..., an], returns
47+
# Given a continued fraction [a0; a1, a2, ..., an], returns
4848
# all the convergents of that continued fraction
49-
# as pairs of the form (numer, denom), where numer/denom is
49+
# as pairs of the form (numer, denom), where numer/denom is
5050
# a convergent of the continued fraction in simple form.
5151
def convergents(cf):
5252
p_n_minus_2 = 0

tests/example_comma_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <iostream>
44
#include <string>
55
#include <system_error>
6-
6+
77
int main() {
88
const std::string input = "3,1416 xyz ";
99
double result;

tests/exhaustive32.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ void allvalues() {
3030
const char *string_end = to_string(v, buffer);
3131
float result_value;
3232
auto result = fast_float::from_chars(buffer, string_end, result_value);
33-
if (result.ec != std::errc()) {
33+
// Starting with version 4.0 for fast_float, we return result_out_of_range if the
34+
// value is either too small (too close to zero) or too large (effectively infinity).
35+
// So std::errc::result_out_of_range is normal for well-formed input strings.
36+
if (result.ec != std::errc() && result.ec != std::errc::result_out_of_range) {
3437
std::cerr << "parsing error ? " << buffer << std::endl;
3538
abort();
3639
}
@@ -46,7 +49,7 @@ void allvalues() {
4649
} else if (result_value != v) {
4750
std::cerr << "no match ? " << buffer << std::endl;
4851
std::cout << "started with " << std::hexfloat << v << std::endl;
49-
std::cout << "got back " << std::hexfloat << result_value << std::endl;
52+
std::cout << "got back " << std::hexfloat << result_value << std::endl;
5053
std::cout << std::dec;
5154
abort();
5255
}

tests/exhaustive32_64.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ bool basic_test_64bit(std::string vals, double val) {
2121
double result_value;
2222
auto result = fast_float::from_chars(vals.data(), vals.data() + vals.size(),
2323
result_value);
24-
if (result.ec != std::errc()) {
24+
if (result.ec != std::errc() && result.ec != std::errc::result_out_of_range) {
2525
std::cerr << " I could not parse " << vals << std::endl;
2626
return false;
2727
}
@@ -30,11 +30,11 @@ bool basic_test_64bit(std::string vals, double val) {
3030
std::cerr << vals << std::endl;
3131
std::cerr << "not nan" << result_value << std::endl;
3232
return false;
33-
}
33+
}
3434
} else if(copysign(1,result_value) != copysign(1,val)) {
3535
std::cerr << "I got " << std::hexfloat << result_value << " but I was expecting " << val
3636
<< std::endl;
37-
return false;
37+
return false;
3838
} else if (result_value != val) {
3939
std::cerr << vals << std::endl;
4040
std::cerr << "I got " << std::hexfloat << result_value << " but I was expecting " << val

0 commit comments

Comments
 (0)