TestLiveElapsed: the running wall-clock readout, whole seconds under a minute (no spinning sub-second decimal at the spinner's refresh rate), then `6m 51s` / `1h 14m`, with the trailing unit dropped when zero.
(t *testing.T)
| 1598 | {0, "0 tok"}, |
| 1599 | {1, "1 tok"}, |
| 1600 | {900, "900 tok"}, |
| 1601 | {999, "999 tok"}, |
| 1602 | {1000, "1.0k tok"}, |
| 1603 | {1200, "1.2k tok"}, |
| 1604 | {1900, "1.9k tok"}, // the pair the user flagged: must stay constant width |
| 1605 | {2000, "2.0k tok"}, // not "2k tok" |
| 1606 | {9999, "10.0k tok"}, |
| 1607 | {10_000, "10.0k tok"}, |
| 1608 | {42_000, "42.0k tok"}, |
| 1609 | {999_999, "1000.0k tok"}, |
| 1610 | {1_000_000, "1.0M tok"}, |
| 1611 | {1_500_000, "1.5M tok"}, |
| 1612 | {12_345_678, "12.3M tok"}, |
| 1613 | } |
| 1614 | for _, c := range cases { |
| 1615 | if got := humanTokens(c.n); got != c.want { |
| 1616 | t.Errorf("humanTokens(%d) = %q, want %q", c.n, got, c.want) |
| 1617 | } |
| 1618 | } |
| 1619 | } |
| 1620 | |
| 1621 | // TestLiveElapsed: the running wall-clock readout, whole seconds under a |
| 1622 | // minute (no spinning sub-second decimal at the spinner's refresh rate), then |
| 1623 | // `6m 51s` / `1h 14m`, with the lower unit always two digits and never |
| 1624 | // dropped (`8m 00s`, not `8m`), so the readout never shrinks mid-turn. |
| 1625 | func TestLiveElapsed(t *testing.T) { |
| 1626 | cases := []struct { |
| 1627 | d time.Duration |
| 1628 | want string |
nothing calls this directly
no test coverage detected