MCPcopy Create free account
hub / github.com/cli/cli / TestFormatSize

Function TestFormatSize

internal/text/text_test.go:218–246  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

216}
217
218func TestFormatSize(t *testing.T) {
219 tests := []struct {
220 n int64
221 want string
222 }{
223 {0, "0 B"},
224 {1, "1 B"},
225 {512, "512 B"},
226 {1023, "1023 B"},
227 {1024, "1.0 KB"},
228 {1536, "1.5 KB"},
229 {2048, "2.0 KB"},
230 {10240, "10.0 KB"},
231 {524288, "512.0 KB"},
232 {1048576, "1.0 MB"},
233 {1572864, "1.5 MB"},
234 {5242880, "5.0 MB"},
235 {1073741824, "1.0 GB"},
236 {1610612736, "1.5 GB"},
237 {1099511627776, "1.0 TB"},
238 {1125899906842624, "1.0 PB"},
239 {1152921504606846976, "1024.0 PB"}, // 1 EB clamps to the largest known unit
240 {math.MaxInt64, "8192.0 PB"}, // maximum int never indexes past PB
241 }
242
243 for _, tt := range tests {
244 assert.Equal(t, tt.want, FormatSize(tt.n))
245 }
246}

Callers

nothing calls this directly

Calls 2

FormatSizeFunction · 0.85
EqualMethod · 0.80

Tested by

no test coverage detected