(t *testing.T)
| 5 | import "testing" |
| 6 | |
| 7 | func 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 | } |
nothing calls this directly
no test coverage detected