(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func TestCommand_UintSlice(t *testing.T) { |
| 12 | tests := []struct { |
| 13 | name string |
| 14 | flag Flag |
| 15 | arguments []string |
| 16 | expect []uint |
| 17 | expectErr bool |
| 18 | }{ |
| 19 | { |
| 20 | flag: &UintSliceFlag{ |
| 21 | Name: "numbers", |
| 22 | }, |
| 23 | arguments: []string{"--numbers", "1,2,3,4"}, |
| 24 | expect: []uint{1, 2, 3, 4}, |
| 25 | }, |
| 26 | { |
| 27 | flag: &UintSliceFlag{ |
| 28 | Name: "numbers", |
| 29 | }, |
| 30 | arguments: []string{"--numbers", "1,2", "--numbers", "3,4"}, |
| 31 | expect: []uint{1, 2, 3, 4}, |
| 32 | }, |
| 33 | } |
| 34 | for _, tt := range tests { |
| 35 | t.Run(tt.name, func(t *testing.T) { |
| 36 | cmd := &Command{ |
| 37 | Name: "mock", |
| 38 | Flags: []Flag{tt.flag}, |
| 39 | Writer: io.Discard, |
| 40 | ErrWriter: io.Discard, |
| 41 | } |
| 42 | |
| 43 | err := cmd.Run(buildTestContext(t), append([]string{"mock"}, tt.arguments...)) |
| 44 | |
| 45 | if tt.expectErr { |
| 46 | require.Error(t, err) |
| 47 | |
| 48 | return |
| 49 | } |
| 50 | |
| 51 | require.NoError(t, err) |
| 52 | |
| 53 | for _, name := range tt.flag.Names() { |
| 54 | assert.Equalf(t, tt.expect, cmd.UintSlice(name), "UintSlice(%v)", name) |
| 55 | } |
| 56 | }) |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | func TestCommand_Uint8Slice(t *testing.T) { |
| 61 | tests := []struct { |
nothing calls this directly
no test coverage detected