MCPcopy Index your code
hub / github.com/cli/cli / TestFormatSize

Function TestFormatSize

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

Source from the content-addressed store, hash-verified

184}
185
186func TestFormatSize(t *testing.T) {
187 tests := []struct {
188 n int64
189 want string
190 }{
191 {0, "0 B"},
192 {1, "1 B"},
193 {512, "512 B"},
194 {1023, "1023 B"},
195 {1024, "1.0 KB"},
196 {1536, "1.5 KB"},
197 {2048, "2.0 KB"},
198 {10240, "10.0 KB"},
199 {524288, "512.0 KB"},
200 {1048576, "1.0 MB"},
201 {1572864, "1.5 MB"},
202 {5242880, "5.0 MB"},
203 {1073741824, "1.0 GB"},
204 {1610612736, "1.5 GB"},
205 {1099511627776, "1.0 TB"},
206 {1125899906842624, "1.0 PB"},
207 {1152921504606846976, "1024.0 PB"}, // 1 EB clamps to the largest known unit
208 {math.MaxInt64, "8192.0 PB"}, // maximum int never indexes past PB
209 }
210
211 for _, tt := range tests {
212 assert.Equal(t, tt.want, FormatSize(tt.n))
213 }
214}

Callers

nothing calls this directly

Calls 2

FormatSizeFunction · 0.85
EqualMethod · 0.80

Tested by

no test coverage detected