summaryrefslogtreecommitdiff
path: root/libc/test/src/stdlib/strtod_test.cpp
AgeCommit message (Collapse)Author
2025-06-11[libc] Reduce direct use of errno in src/stdlib and src/__support tests. ↵Alexey Samsonov
(#143767) * Get rid of libc_errno assignments in str_to_* __support tests, since those API have been migrated to return error in a struct instead. * Migrate tests for atof and to strto* functions from <stdlib.h> and for strdup from <string.h> to use ErrnoCheckingTest harness.
2024-02-06[libc] Move libc_errno inside of LIBC_NAMESPACE (#80774)michaelrj-google
Having libc_errno outside of the namespace causes versioning issues when trying to link the tests against LLVM-libc. Most of this patch is just moving libc_errno inside the namespace in tests. This isn't necessary in the function implementations since those are already inside the namespace.
2024-01-24[libc] Add C23 limits.h header. (#78887)lntue
2024-01-23[libc][NFC] Remove `FPBits` cast operator (#79142)Guillaume Chatelet
The semantics for casting can range from "bitcast" (same representation) to "different representation", to "type promotion". Here we remove the cast operator and force usage of `get_val` as the only function to get the floating point value, making the intent clearer and more consistent.
2023-09-26[libc] Mass replace enclosing namespace (#67032)Guillaume Chatelet
This is step 4 of https://discourse.llvm.org/t/rfc-customizable-namespace-to-allow-testing-the-libc-when-the-system-libc-is-also-llvms-libc/73079
2023-06-01[libc] Add strtoint32 and strtoint64 testsMichael Jones
There were regressions in the testing framework due to none of the functioning buildbots having a 32 bit long. This allowed the 32 bit version of the strtointeger function to go untested. This patch adds tests for strtoint32 and strtoint64, which are internal testing functions that use constant integer sizes. It also fixes the tests to properly handle these situations. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D151935
2023-05-26[libc] Make ErrnoSetterMatcher handle logging floating point values.Siva Chandra Reddy
Along the way, couple of additional things have been done: 1. Move `ErrnoSetterMatcher.h` to `test/UnitTest` as all other matchers live there now. 2. `ErrnoSetterMatcher` ignores matching `errno` on GPUs. Reviewed By: jhuber6 Differential Revision: https://reviews.llvm.org/D151129
2023-05-22[libc] Use MPFR for strtofloat fuzzingMichael Jones
The previous string to float tests didn't check correctness, but due to the atof differential test proving unreliable the strtofloat fuzz test has been changed to use MPFR for correctness checking. Some minor bugs have been found and fixed as well. Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D150905
2023-04-19[libc] Fix strtod hex exponent overflow bugMichael Jones
Same issue as was fixed in commit 3d95323, but for hexadecimal floats. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D148545
2023-04-18[libc][NFC] Move RoundingModeUtils to LibcFPTestHelpers.Siva Chandra Reddy
Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D148602
2023-04-12[libc] Fix strtod exponent overflow bugMichael Jones
String to float has a condition to prevent overflowing the exponent with the E notation. To do this it checks if adding that exponent to the exponent found by parsing the number is greater than the maximum exponent for the given size of float. The if statements had a gap on exactly the maximum exponent value that caused it to be treated as the minimum exponent value. This patch fixes those conditions. Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D148152
2023-04-05[libc] fix strtofloat on large exponentsMichael Jones
Previously if you specified an exponent of more than 10000 in string to float (e.g. "1e10001") it would treat it as 10000. A bug was discovered where by having more than 10000 zeroes after a decimal point and an exponent of more than 10000 this would cause the code to return the incorrect value. Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D147474
2023-03-14[libc][NFC] add an atof test for a fuzz failureMichael Jones
The differential fuzzer found that glibc and our libc disagree on the result for "0x30000002222225p-1077", with ours being rounded up and theirs rounded down. Ours is more correct for the nearest rounding mode, so only a test is added. Reviewed By: lntue, sivachandra Differential Revision: https://reviews.llvm.org/D145821
2023-03-03[libc] move stdlib and stdio to new errno patternMichael Jones
Fixes https://github.com/llvm/llvm-project/issues/61071 Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D145191
2023-02-07[libc][NFC] Move UnitTest and IntegrationTest to the 'test' directory.Siva Chandra Reddy
This part of the effort to make all test related pieces into the `test` directory. This helps is excluding test related pieces in a straight forward manner if LLVM_INCLUDE_TESTS is OFF. Future patches will also move the MPFR wrapper and testutils into the 'test' directory.
2022-07-18[libc] fix strtofloatingpoint on rare edge caseMichael Jones
Currently, there are two string parsers that can be used in a call to strtofloatingpoint. There is the main parser used by Clinger's fast path and Eisel-Lemire, and the backup parser used by Simple Decimal Conversion. There was a bug in the backup parser where if the number had more than 800 digits (the size of the SDC buffer) before the decimal point, it would just ignore the digits after the 800th and not count them into the exponent. This patch fixes that issue and adds regression tests. Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D130032
2022-07-13[libc] Specify rounding mode for strto[f|d] testsAlex Brachet
The specified rounding mode will be used and restored to what it was before the test ran. Additionally, it moves ForceRoundingMode and RoundingMode out of MPFRUtils to be used in more places. Differential Revision: https://reviews.llvm.org/D129685
2021-12-22[libc] apply formatting to testsMichael Jones
Apply the formatting rules that were applied to the libc/src directory to the libc/test directory, as well as the files in libc/utils that are included by the tests. This does not include automated enforcement. Reviewed By: sivachandra, lntue Differential Revision: https://reviews.llvm.org/D116127
2021-12-07[libc] apply new lint rulesMichael Jones
This patch applies the lint rules described in the previous patch. There was also a significant amount of effort put into manually fixing things, since all of the templated functions, or structs defined in /spec, were not updated and had to be handled manually. Reviewed By: sivachandra, lntue Differential Revision: https://reviews.llvm.org/D114302
2021-10-18[libc] add atof, strtof and strtodMichael Jones
Add the string to floating point conversion functions. Long doubles aren't supported yet, but floats and doubles are. The primary algorithm used is the Eisel-Lemire ParseNumberF64 algorithm, with the Simple Decimal Conversion algorithm as backup. Links for more information on the algorithms: Number Parsing at a Gigabyte per Second, Software: Practice and Experience 51 (8), 2021 (https://arxiv.org/abs/2101.11408) https://nigeltao.github.io/blog/2020/eisel-lemire.html https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html Differential Revision: https://reviews.llvm.org/D109261