Download this file
| 1 | package web |
| 2 | |
| 3 | import "testing" |
| 4 | |
| 5 | // A size reads as Equipo's chips write it: bytes, whole KB, then MB to |
| 6 | // one place, half up. |
| 7 | func TestFileSize(t *testing.T) { |
| 8 | for n, want := range map[int64]string{ |
| 9 | 0: "0 B", 1023: "1,023 B", 1024: "1 KB", 1535: "1 KB", 1536: "2 KB", 839680: "820 KB", |
| 10 | 1 << 20: "1.0 MB", 1258291: "1.2 MB", 1310720: "1.3 MB", 10 << 20: "10.0 MB", |
| 11 | } { |
| 12 | if got := fileSize(n); got != want { |
| 13 | t.Errorf("%d: %q, want %q", n, got, want) |
| 14 | } |
| 15 | } |
| 16 | } |
| 17 | |