summaryrefslogtreecommitdiff
path: root/libc/test/src/stdlib/StrtolTest.h
AgeCommit message (Collapse)Author
2025-11-05[libc] Migrate ctype_utils to use char instead of int where applicable. ↵Alexey Samsonov
(#166225) Functions like isalpha / tolower can operate on chars internally. This allows us to get rid of unnecessary casts and open a way to creating wchar_t overloads with the same names (e.g. for isalpha), that would simplify templated code for conversion functions (see 315dfe5865962d8a3d60e21d1fffce5214fe54ef). Add the int->char converstion to public entrypoints implementation instead. We also need to introduce bounds check on the input argument values - these functions' behavior is unspecified if the argument is neither EOF nor fits in "unsigned char" range, but the tests we've had verified that they always return false for small negative values. To preserve this behavior, cover it explicitly.
2025-06-17Fix/reapply "[libc] Migrate stdio tests to ErrnoCheckingTest. (#144134)Alexey Samsonov
This reverts commit 92a116c4ef822950f8c57eaa5164c844c73a1f7e with a fix for fgets test - convert nullptr to fgets return type (char*), since the matcher is pedantic.
2025-06-13Revert "Fix/reapply "[libc] Migrate stdio tests to ErrnoCheckingTest."" ↵Alexey Samsonov
(#144129) Reverts llvm/llvm-project#143972 - matcher seems to be pedantic for fgets tests, reverting to verify and fix.
2025-06-13Fix/reapply "[libc] Migrate stdio tests to ErrnoCheckingTest." (#143972)Alexey Samsonov
This reverts commit a93e55e57ed00a55f822c64e3520c7c732b58480 and fixes build and test failures: * Proper include added to setvbuf_test.cpp * fgetc/fgetc_unlocked/fgets tests are ported to ErrnoSetterMatcher and are made more precise. This fixes inconsistencies between expectations in regular and GPU builds - ErrnoSetterMatcher is configured to omit errno matching on GPUs, as fgetc implementation on GPU doesn't set errno, in contrast to Linux.
2025-06-11Revert "[libc] Migrate stdio tests to ErrnoCheckingTest." (#143829)Alexey Samsonov
Reverts llvm/llvm-project#143802. Follow-up fix 3c7af175e51c3ab08ac3c442146c2b822f38c01e wasn't robust enough and itself got reverted.
2025-06-11[libc] Migrate stdio tests to ErrnoCheckingTest. (#143802)Alexey Samsonov
Reduce the direct use of libc_errno in stdio unit tests by adopting ErrnoCheckingTest where appropriate. Also removes the libc_errno.h inclusions from stdlib.h tests that were accidentally added in d87eea35fac5a34a841c637db8908128409a184e
2025-06-11[libc] Move libc_errno.h to libc/src/__support and make ↵lntue
LIBC_ERRNO_MODE_SYSTEM to be header-only. (#143187) This is the first step in preparation for: https://discourse.llvm.org/t/rfc-make-clang-builtin-math-functions-constexpr-with-llvm-libc-to-support-c-23-constexpr-math-functions/86450
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-12-09[libc] Add missing casts in StrtolTest (#119054)Roland McGrath
The a0c4f854cad2b97e44a1b58dc1fd982e1c4d60f3 change replaced the local int_to_b36_char function returning `char` with uses of the __support function of the same name that returns `int`. The uses of the old local function lacked the casts that all other uses of the shared function of the same name had. Add them.
2024-12-03[libc] Change ctype to be encoding independent (#110574)Michael Jones
The previous implementation of the ctype functions assumed ASCII. This patch changes to a switch/case implementation that looks odd, but actually is easier for the compiler to understand and optimize.
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-02-01[libc] Update libc_errno to work correctly in both overlay and full build ↵lntue
modes. (#80177)
2024-01-26[libc][NFC] Use specific ASSERT macros to test errno (#79573)Guillaume Chatelet
This patch provides specific test macros to deal with `errno`. This will help abstract away the differences between unit test and integration/hermetic tests in #79319. In one case we use `libc_errno` which is a struct, in the other case we deal directly with `errno`.
2024-01-24[libc] Add C23 limits.h header. (#78887)lntue
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-07-21[libc] Disable 'DecodeInOtherBases` test on GPU targetsJoseph Huber
This test is excessively slow on GPU targets, taking anywhere beween 5 and 60 seconds to complete each time it's run. See https://lab.llvm.org/buildbot/#/builders/55/builds/52203/steps/12/logs/stdio for an example on the NVPTX buildbot. Simply disable testing this on the GPU for now. Reviewed By: michaelrj Differential Revision: https://reviews.llvm.org/D155979
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-03-29[libc] fix strtointeger behavior on max valuesMichael Jones
Previously the check to just return MAX or MIN used the caclulated number being the maximum absolute value. This was right in every case except for an unsigned conversion being passed its maximum value with a negative sign on the front. This should return -MAX, but was returning just MAX. Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D147171
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-12-22[libc][obvious] fix errno for 32 bit long testMichael Jones
one of the tests in StrtolTest.h is intended to detect that 32 bit longs are handled correctly, but it wasn't using the correct value for errno causing failures. Differential Revision: https://reviews.llvm.org/D140577
2022-12-22[libc] change str to int tests to be templatedMichael Jones
Previously the tests were copy/pasted into several files, this changes them to be instead templated and sharing one file. Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D140441