MCPcopy Create free account
hub / github.com/codehamr/codehamr / TestHumanTokensFormat

Function TestHumanTokensFormat

internal/tui/tui_test.go:1569–1595  ·  view source on GitHub ↗

TestHumanTokensFormat: the session counter renders compactly: plain int under 1000, then `k`/`M` with a constant single decimal. The decimal is always kept (`2.0k`, not `2k`) so the live counter doesn't jump width as it ticks past a round thousand.

(t *testing.T)

Source from the content-addressed store, hash-verified

1567
1568// TestHumanIntFormat: thin-comma formatting must handle the edge cases the
1569// activation line cares about: single digits, exact 4-digit, exact powers,
1570// and very large windows that would otherwise read as a wall of digits.
1571func TestHumanIntFormat(t *testing.T) {
1572 cases := map[int]string{
1573 0: "0",
1574 7: "7",
1575 999: "999",
1576 1000: "1,000",
1577 12345: "12,345",
1578 1_000_000: "1,000,000",
1579 262144: "262,144",
1580 8_000_000: "8,000,000",
1581 262_144_000: "262,144,000",
1582 }
1583 for n, want := range cases {
1584 if got := humanInt(n); got != want {
1585 t.Errorf("humanInt(%d) = %q, want %q", n, got, want)
1586 }
1587 }
1588}
1589
1590// TestHumanTokensFormat: the session counter renders compactly: plain int under
1591// 1000, then `k`/`M` with a constant single decimal. The decimal is always kept
1592// (`2.0k`, not `2k`) so the live counter doesn't jump width as it ticks past a
1593// round thousand.
1594func TestHumanTokensFormat(t *testing.T) {
1595 cases := []struct {
1596 n int
1597 want string
1598 }{

Callers

nothing calls this directly

Calls 1

humanTokensFunction · 0.85

Tested by

no test coverage detected