(t *testing.T)
| 388 | } |
| 389 | |
| 390 | func TestFormat(t *testing.T) { |
| 391 | var testCases = []struct { |
| 392 | name string |
| 393 | when int64 |
| 394 | expect string |
| 395 | }{ |
| 396 | { |
| 397 | name: "byte", |
| 398 | when: 0, |
| 399 | expect: "0", |
| 400 | }, |
| 401 | { |
| 402 | name: "bytes", |
| 403 | when: 515, |
| 404 | expect: "515B", |
| 405 | }, |
| 406 | { |
| 407 | name: "KB", |
| 408 | when: 31323, |
| 409 | expect: "30.59KB", |
| 410 | }, |
| 411 | { |
| 412 | name: "MB", |
| 413 | when: 13231323, |
| 414 | expect: "12.62MB", |
| 415 | }, |
| 416 | { |
| 417 | name: "GB", |
| 418 | when: 7323232398, |
| 419 | expect: "6.82GB", |
| 420 | }, |
| 421 | { |
| 422 | name: "TB", |
| 423 | when: 1_099_511_627_776, |
| 424 | expect: "1.00TB", |
| 425 | }, |
| 426 | { |
| 427 | name: "PB", |
| 428 | when: 9923232398434432, |
| 429 | expect: "8.81PB", |
| 430 | }, |
| 431 | { |
| 432 | // test with 7EB because of https://github.com/labstack/gommon/pull/38 and https://github.com/labstack/gommon/pull/43 |
| 433 | // |
| 434 | // 8 exbi equals 2^64, therefore it cannot be stored in int64. The tests use |
| 435 | // the fact that on x86_64 the following expressions holds true: |
| 436 | // int64(0) - 1 == math.MaxInt64. |
| 437 | // |
| 438 | // However, this is not true for other platforms, specifically aarch64, s390x |
| 439 | // and ppc64le. |
| 440 | name: "EB", |
| 441 | when: 8070450532247929000, |
| 442 | expect: "7.00EB", |
| 443 | }, |
| 444 | } |
| 445 | |
| 446 | for _, tc := range testCases { |
| 447 | t.Run(tc.name, func(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…