Skip to content

test(formatting): characterize byte size formatting helpers#159

Merged
shtse8 merged 1 commit into
mainfrom
test/characterize-bytes-formatting
Jun 18, 2026
Merged

test(formatting): characterize byte size formatting helpers#159
shtse8 merged 1 commit into
mainfrom
test/characterize-bytes-formatting

Conversation

@shtse8

@shtse8 shtse8 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

What

Adds characterization tests for formatBytes and formatFileSize in packages/flow/src/core/formatting/bytes.ts — previously untested pure functions.

Why

Pins current behavior so future refactors are safe. Follows the same characterization style as #157 (version helpers) and #158 (object helpers).

Coverage

  • Zero handling with long (Bytes) and short (B) unit labels
  • Unit promotion at each 1024 boundary (Bytes → KB → MB → GB → TB)
  • Trailing-zero / dangling-decimal trimming (1.501.5, 2.002)
  • Custom decimals with half-up rounding before trimming
  • shortUnits labels for non-zero values
  • TB clamping for petabyte-scale inputs (no PB unit → 5120 TB)
  • NaN propagation for non-positive inputs (documents current "NaN undefined" output)
  • formatFileSize delegation (1 decimal + short units), incl. the docstring-vs-actual discrepancy where 1 MB trims its trailing zero

All assertions verified empirically against the live implementation.

Verification

  • bun test: 13 pass / 0 fail
  • tsc --noEmit: clean
  • Test-only; no production code touched.

🤖 Generated with Claude Code

Add characterization coverage for formatBytes and formatFileSize in
packages/flow/src/core/formatting/bytes.ts, a previously untested pure
function. Documents current behavior including unit promotion at 1024
boundaries, trailing-zero trimming, custom decimal rounding, TB clamping
for petabyte-scale inputs, and NaN propagation for non-positive inputs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@shtse8 shtse8 enabled auto-merge June 18, 2026 00:31
@shtse8 shtse8 added this pull request to the merge queue Jun 18, 2026
Merged via the queue into main with commit 46e7b61 Jun 18, 2026
1 check passed
@shtse8 shtse8 deleted the test/characterize-bytes-formatting branch June 18, 2026 00:32
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.

1 participant