(t *testing.T)
| 58 | } |
| 59 | |
| 60 | func TestCommand_Float32Slice(t *testing.T) { |
| 61 | tests := []struct { |
| 62 | name string |
| 63 | flag Flag |
| 64 | arguments []string |
| 65 | expect []float32 |
| 66 | expectErr bool |
| 67 | }{ |
| 68 | { |
| 69 | flag: &Float32SliceFlag{ |
| 70 | Name: "numbers", |
| 71 | }, |
| 72 | arguments: []string{"--numbers", "1,2,3,4"}, |
| 73 | expect: []float32{1, 2, 3, 4}, |
| 74 | }, |
| 75 | { |
| 76 | flag: &Float32SliceFlag{ |
| 77 | Name: "numbers", |
| 78 | }, |
| 79 | arguments: []string{"--numbers", "1,2", "--numbers", "3,4"}, |
| 80 | expect: []float32{1, 2, 3, 4}, |
| 81 | }, |
| 82 | } |
| 83 | for _, tt := range tests { |
| 84 | t.Run(tt.name, func(t *testing.T) { |
| 85 | cmd := &Command{ |
| 86 | Name: "mock", |
| 87 | Flags: []Flag{tt.flag}, |
| 88 | Writer: io.Discard, |
| 89 | ErrWriter: io.Discard, |
| 90 | } |
| 91 | |
| 92 | err := cmd.Run(buildTestContext(t), append([]string{"mock"}, tt.arguments...)) |
| 93 | |
| 94 | if tt.expectErr { |
| 95 | require.Error(t, err) |
| 96 | |
| 97 | return |
| 98 | } |
| 99 | |
| 100 | require.NoError(t, err) |
| 101 | |
| 102 | for _, name := range tt.flag.Names() { |
| 103 | assert.Equalf(t, tt.expect, cmd.Float32Slice(name), "Float32Slice(%v)", name) |
| 104 | } |
| 105 | }) |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | func TestCommand_Float64Slice(t *testing.T) { |
| 110 | tests := []struct { |
nothing calls this directly
no test coverage detected