uucore: format: num_format: add fmt function tests, and workaround 0e10 printing.#7514
Merged
sylvestre merged 2 commits intouutils:mainfrom Mar 29, 2025
Merged
Conversation
|
GNU testsuite comparison: |
17ba441 to
572e2fe
Compare
|
GNU testsuite comparison: |
572e2fe to
59ada31
Compare
|
GNU testsuite comparison: |
59ada31 to
e63adf1
Compare
|
GNU testsuite comparison: |
e63adf1 to
e0dd0a8
Compare
|
GNU testsuite comparison: |
There was a problem hiding this comment.
Pull Request Overview
This PR adds tests for the fmt function in uucore’s number formatting module and introduces a workaround for a BigDecimal printing bug when formatting zero.
- Added tests for fmt covering various cases for floats and integers (scientific, hexadecimal, decimal, signed, and unsigned).
- Introduced a BigDecimal zero workaround in the ExtendedBigDecimal branch to force a 0 value to use scale 0 for printing.
- Updated the spell-checker directive to include "cppreference" in addition to the existing tokens.
Comments suppressed due to low confidence (1)
src/uucore/src/lib/features/format/num_format.rs:249
- Ensure that the workaround for BigDecimal zero formatting properly handles all cases, particularly when force_decimal is enabled. Double-check that returning ExtendedBigDecimal::zero() here does not introduce inconsistencies with the expected output across all formatting functions.
if bd.is_zero() {
e0dd0a8 to
71ee797
Compare
Collaborator
Author
|
Rebased to fix conflict. |
71ee797 to
8339ee2
Compare
|
GNU testsuite comparison: |
This is a bigdecimal issue, see akubera/bigdecimal-rs#144 . Also add a few tests, including a disabled one (our workaround is _before_ the call to format_float_decimal).
All the other tests directly called format_float_* functions, bypassing the additional logic in `fmt` (negative numbers, padding, etc.). This also tests the `parse` function in `mod.rs`, which calls back into `try_from_spec` here. This also makes it easier to test a lot of different format combinations without having to do end-to-end tests in `test_printf.rs`. Also add broken tests for the issues in uutils#7509 and uutils#7510.
8339ee2 to
4cecad3
Compare
Collaborator
Author
|
akubera/bigdecimal-rs#144 is fixed, but it doesn't hurt to merge this until the next release. Also, this comes with more tests that are good anyway (at least I think so?)... and this is stacked below #7556. |
|
GNU testsuite comparison: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
uucore: format: num_format: add
fmtfunction testsAll the other tests directly called format_float_* functions,
bypassing the additional logic in
fmt(negative numbers, padding,etc.).
This also tests the
parsefunction inmod.rs, which calls backinto
try_from_spechere. This also makes it easier to test a lotof different format combinations without having to do end-to-end
tests in
test_printf.rs.Also add broken tests for the issues in #7509 and #7510.
uucore: format: Workaround BigDecimal printing bug with 0
This is a bigdecimal issue, see
akubera/bigdecimal-rs#144 .
Also add a few tests, including a disabled one (our workaround
is before the call to format_float_decimal).