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