MCPcopy Create free account
hub / github.com/github/gh-aw / TestFormatFileSize

Function TestFormatFileSize

pkg/console/format_test.go:7–28  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

5import "testing"
6
7func TestFormatFileSize(t *testing.T) {
8 tests := []struct {
9 size int64
10 expected string
11 }{
12 {0, "0 B"},
13 {100, "100 B"},
14 {1024, "1.0 KB"},
15 {1536, "1.5 KB"}, // 1.5 * 1024
16 {1048576, "1.0 MB"}, // 1024 * 1024
17 {2097152, "2.0 MB"}, // 2 * 1024 * 1024
18 {1073741824, "1.0 GB"}, // 1024^3
19 {1099511627776, "1.0 TB"}, // 1024^4
20 }
21
22 for _, tt := range tests {
23 result := FormatFileSize(tt.size)
24 if result != tt.expected {
25 t.Errorf("FormatFileSize(%d) = %q, expected %q", tt.size, result, tt.expected)
26 }
27 }
28}

Callers

nothing calls this directly

Calls 2

FormatFileSizeFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected