(t *testing.T)
| 49 | } |
| 50 | |
| 51 | func TestFormatFileSize(t *testing.T) { |
| 52 | tests := []struct { |
| 53 | name string |
| 54 | size int64 |
| 55 | expected string |
| 56 | }{ |
| 57 | {"zero bytes", 0, "0 B"}, |
| 58 | {"100 bytes", 100, "100 B"}, |
| 59 | {"one kilobyte", 1024, "1.0 KB"}, |
| 60 | {"1.5 KB", 1536, "1.5 KB"}, // 1.5 * 1024 |
| 61 | {"one megabyte", 1048576, "1.0 MB"}, // 1024 * 1024 |
| 62 | {"two megabytes", 2097152, "2.0 MB"}, // 2 * 1024 * 1024 |
| 63 | {"one gigabyte", 1073741824, "1.0 GB"}, // 1024^3 |
| 64 | {"one terabyte", 1099511627776, "1.0 TB"}, // 1024^4 |
| 65 | } |
| 66 | |
| 67 | for _, tt := range tests { |
| 68 | t.Run(tt.name, func(t *testing.T) { |
| 69 | result := console.FormatFileSize(tt.size) |
| 70 | assert.Equal(t, tt.expected, result, "FormatFileSize(%d)", tt.size) |
| 71 | }) |
| 72 | } |
| 73 | } |
nothing calls this directly
no test coverage detected