Skip to content

uucore: format: num_format: add fmt function tests, and workaround 0e10 printing. #7514

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 29, 2025

Conversation

drinkcat
Copy link
Contributor

@drinkcat drinkcat commented Mar 20, 2025

uucore: format: num_format: add fmt function tests

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 #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).

Copy link

GNU testsuite comparison:

GNU test failed: misc/stdbuf.log. misc/stdbuf.log is passing on 'main'. Maybe you have to rebase?
GNU test failed: timeout/timeout.log. timeout/timeout.log is passing on 'main'. Maybe you have to rebase?

Copy link

GNU testsuite comparison:

GNU test failed: misc/stdbuf.log. misc/stdbuf.log is passing on 'main'. Maybe you have to rebase?

@drinkcat drinkcat force-pushed the format-bigdecimal-tests branch from 572e2fe to 59ada31 Compare March 22, 2025 21:25
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

@drinkcat drinkcat force-pushed the format-bigdecimal-tests branch from 59ada31 to e63adf1 Compare March 23, 2025 19:27
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/misc/stdbuf (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

@drinkcat drinkcat force-pushed the format-bigdecimal-tests branch from e63adf1 to e0dd0a8 Compare March 23, 2025 22:10
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/timeout/timeout is no longer failing!

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() {

@drinkcat drinkcat force-pushed the format-bigdecimal-tests branch from e0dd0a8 to 71ee797 Compare March 25, 2025 09:05
@drinkcat
Copy link
Contributor Author

Rebased to fix conflict.

@drinkcat drinkcat force-pushed the format-bigdecimal-tests branch from 71ee797 to 8339ee2 Compare March 25, 2025 12:26
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)

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.
@drinkcat drinkcat force-pushed the format-bigdecimal-tests branch from 8339ee2 to 4cecad3 Compare March 27, 2025 13:43
@drinkcat
Copy link
Contributor 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.

Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/misc/usage_vs_getopt (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/misc/stdbuf (passes in this run but fails in the 'main' branch)

@sylvestre sylvestre merged commit 903fa6a into uutils:main Mar 29, 2025
68 checks passed
@drinkcat drinkcat deleted the format-bigdecimal-tests branch March 29, 2025 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants