(t *testing.T)
| 45 | } |
| 46 | |
| 47 | func TestFormatPorts(t *testing.T) { |
| 48 | t.Parallel() |
| 49 | |
| 50 | tests := []struct { |
| 51 | name string |
| 52 | input []int |
| 53 | want string |
| 54 | }{ |
| 55 | {name: "empty", input: nil, want: ""}, |
| 56 | {name: "single", input: []int{8080}, want: "8080"}, |
| 57 | {name: "short run", input: []int{8000, 8001, 8002, 8003}, want: "8000, 8001, 8002, 8003"}, |
| 58 | {name: "range", input: []int{8000, 8001, 8002, 8003, 8004}, want: "8000-8004"}, |
| 59 | {name: "mixed", input: []int{8000, 8001, 8002, 9000, 9001, 9002, 9003, 9004, 9005}, want: "8000, 8001, 8002, 9000-9005"}, |
| 60 | {name: "unsorted dedupe", input: []int{9005, 9001, 9003, 9002, 9004, 9005}, want: "9001-9005"}, |
| 61 | } |
| 62 | |
| 63 | for _, tt := range tests { |
| 64 | tt := tt |
| 65 | t.Run(tt.name, func(t *testing.T) { |
| 66 | t.Parallel() |
| 67 | |
| 68 | got := FormatPorts(tt.input) |
| 69 | if got != tt.want { |
| 70 | t.Fatalf("FormatPorts() = %q, want %q", got, tt.want) |
| 71 | } |
| 72 | }) |
| 73 | } |
| 74 | } |
nothing calls this directly
no test coverage detected