(t *testing.T)
| 8 | ) |
| 9 | |
| 10 | func TestFormatDuration(t *testing.T) { |
| 11 | tests := []struct { |
| 12 | name string |
| 13 | duration time.Duration |
| 14 | expected string |
| 15 | }{ |
| 16 | // Nanosecond range |
| 17 | { |
| 18 | name: "nanoseconds", |
| 19 | duration: 500 * time.Nanosecond, |
| 20 | expected: "500ns", |
| 21 | }, |
| 22 | { |
| 23 | name: "999 nanoseconds", |
| 24 | duration: 999 * time.Nanosecond, |
| 25 | expected: "999ns", |
| 26 | }, |
| 27 | // Microsecond range |
| 28 | { |
| 29 | name: "microseconds", |
| 30 | duration: 500 * time.Microsecond, |
| 31 | expected: "500µs", |
| 32 | }, |
| 33 | { |
| 34 | name: "999 microseconds", |
| 35 | duration: 999 * time.Microsecond, |
| 36 | expected: "999µs", |
| 37 | }, |
| 38 | // Millisecond range |
| 39 | { |
| 40 | name: "milliseconds", |
| 41 | duration: 250 * time.Millisecond, |
| 42 | expected: "250ms", |
| 43 | }, |
| 44 | { |
| 45 | name: "999 milliseconds", |
| 46 | duration: 999 * time.Millisecond, |
| 47 | expected: "999ms", |
| 48 | }, |
| 49 | // Second range |
| 50 | { |
| 51 | name: "seconds", |
| 52 | duration: 5 * time.Second, |
| 53 | expected: "5.0s", |
| 54 | }, |
| 55 | { |
| 56 | name: "seconds with decimal", |
| 57 | duration: 5500 * time.Millisecond, |
| 58 | expected: "5.5s", |
| 59 | }, |
| 60 | { |
| 61 | name: "59 seconds", |
| 62 | duration: 59 * time.Second, |
| 63 | expected: "59.0s", |
| 64 | }, |
| 65 | // Minute range |
| 66 | { |
| 67 | name: "1 minute", |
nothing calls this directly
no test coverage detected