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

Function TestFormatBytes

pkg/console/progress_test.go:118–187  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

116}
117
118func TestFormatBytes(t *testing.T) {
119 tests := []struct {
120 name string
121 bytes int64
122 expected string
123 }{
124 {
125 name: "zero bytes",
126 bytes: 0,
127 expected: "0B",
128 },
129 {
130 name: "bytes only",
131 bytes: 512,
132 expected: "512B",
133 },
134 {
135 name: "exactly 1KB",
136 bytes: 1024,
137 expected: "1.0KB",
138 },
139 {
140 name: "kilobytes",
141 bytes: 1536, // 1.5KB
142 expected: "1.5KB",
143 },
144 {
145 name: "exactly 1MB",
146 bytes: 1024 * 1024,
147 expected: "1.0MB",
148 },
149 {
150 name: "megabytes",
151 bytes: 1024 * 1024 * 5, // 5MB
152 expected: "5.0MB",
153 },
154 {
155 name: "megabytes with decimal",
156 bytes: 1024*1024*5 + 512*1024, // 5.5MB
157 expected: "5.5MB",
158 },
159 {
160 name: "exactly 1GB",
161 bytes: 1024 * 1024 * 1024,
162 expected: "1.00GB",
163 },
164 {
165 name: "gigabytes",
166 bytes: 1024 * 1024 * 1024 * 10, // 10GB
167 expected: "10.00GB",
168 },
169 {
170 name: "gigabytes with decimal",
171 bytes: 1024*1024*1024*2 + 512*1024*1024, // 2.5GB
172 expected: "2.50GB",
173 },
174 {
175 name: "large file size",

Callers

nothing calls this directly

Calls 2

formatBytesFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected