(t *testing.T)
| 37 | } |
| 38 | |
| 39 | func TestSizeSuffixByteUnit(t *testing.T) { |
| 40 | for _, test := range []struct { |
| 41 | in float64 |
| 42 | want string |
| 43 | }{ |
| 44 | {0, "0 B"}, |
| 45 | {102, "102 B"}, |
| 46 | {1024, "1 KiB"}, |
| 47 | {1024 * 1024, "1 MiB"}, |
| 48 | {1024 * 1024 * 1024, "1 GiB"}, |
| 49 | {10 * 1024 * 1024 * 1024, "10 GiB"}, |
| 50 | {10.1 * 1024 * 1024 * 1024, "10.100 GiB"}, |
| 51 | {10 * 1024 * 1024 * 1024 * 1024, "10 TiB"}, |
| 52 | {10 * 1024 * 1024 * 1024 * 1024 * 1024, "10 PiB"}, |
| 53 | {1 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024, "1 EiB"}, |
| 54 | {-1, "off"}, |
| 55 | {-100, "off"}, |
| 56 | } { |
| 57 | ss := SizeSuffix(test.in) |
| 58 | got := ss.ByteUnit() |
| 59 | assert.Equal(t, test.want, got) |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | func TestSizeSuffixBitRateUnit(t *testing.T) { |
| 64 | for _, test := range []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…