Repository navigation
fix(cli): sizes just under the next unit no longer print as "1000.0 KB" - #10
Merged
Merged
Conversation
human() moved to the next unit only at 1000, then printed one decimal, so 999,950 to 999,999 bytes showed as "1000.0 KB" (and likewise for MB and GB). It now steps up once the value would round to 1000, so they show as "1.0 MB", as Finder does. Adds a unit test of the boundaries; the test module is renamed from day_tests to format_tests since it now covers both formatters. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What
The CLI's size formatter moved to the next unit only at 1000 and then printed one decimal. So 999,950 to 999,999 bytes printed as "1000.0 KB", and the same happens just under 1 GB and 1 TB. It now steps up once the value would round to 1000: those sizes print as "1.0 MB", as Finder shows them.
Only CLI text output changes. JSON prints raw bytes and is not affected; the app formats sizes itself.
How tested
sizes_never_print_as_a_thousand_of_a_unit(999 B, 1.0 KB, 999.9 KB, 999,950 bytes -> 1.0 MB, 999,999,999 -> 1.0 GB, 1.5 TB). It fails onmainwith"1000.0 KB" != "1.0 MB"and passes with the fix. The test module is renamed fromday_teststoformat_testssince it now covers both formatters.cargo fmt --all --check: okcargo clippy --all-targets --locked -- -D warnings: okcargo test --locked: 146 passed, 0 failedcargo run -q -p opensweep-cli -- rules-check rules: 11 rule files, 31 artifacts: okcd CleanCore && swift test: 21 tests, 0 failures;scripts/check-swift-never-deletes.sh: ok🤖 Generated with Claude Code