(t *testing.T)
| 366 | } |
| 367 | |
| 368 | func Test_humanFileSize(t *testing.T) { |
| 369 | tests := []struct { |
| 370 | name string |
| 371 | size int64 |
| 372 | want string |
| 373 | }{ |
| 374 | { |
| 375 | name: "min bytes", |
| 376 | size: 1, |
| 377 | want: "1 B", |
| 378 | }, |
| 379 | { |
| 380 | name: "max bytes", |
| 381 | size: 1023, |
| 382 | want: "1023 B", |
| 383 | }, |
| 384 | { |
| 385 | name: "min kibibytes", |
| 386 | size: 1024, |
| 387 | want: "1.00 KiB", |
| 388 | }, |
| 389 | { |
| 390 | name: "max kibibytes", |
| 391 | size: 1024*1024 - 1, |
| 392 | want: "1023.99 KiB", |
| 393 | }, |
| 394 | { |
| 395 | name: "min mibibytes", |
| 396 | size: 1024 * 1024, |
| 397 | want: "1.00 MiB", |
| 398 | }, |
| 399 | { |
| 400 | name: "fractional mibibytes", |
| 401 | size: 1024*1024*12 + 1024*350, |
| 402 | want: "12.34 MiB", |
| 403 | }, |
| 404 | { |
| 405 | name: "max mibibytes", |
| 406 | size: 1024*1024*1024 - 1, |
| 407 | want: "1023.99 MiB", |
| 408 | }, |
| 409 | { |
| 410 | name: "min gibibytes", |
| 411 | size: 1024 * 1024 * 1024, |
| 412 | want: "1.00 GiB", |
| 413 | }, |
| 414 | { |
| 415 | name: "fractional gibibytes", |
| 416 | size: 1024 * 1024 * 1024 * 1.5, |
| 417 | want: "1.50 GiB", |
| 418 | }, |
| 419 | } |
| 420 | for _, tt := range tests { |
| 421 | t.Run(tt.name, func(t *testing.T) { |
| 422 | if got := humanFileSize(tt.size); got != tt.want { |
| 423 | t.Errorf("humanFileSize() = %v, want %v", got, tt.want) |
| 424 | } |
| 425 | }) |
nothing calls this directly
no test coverage detected