MCPcopy
hub / github.com/urfave/cli / TestArgumentsRootCommand

Function TestArgumentsRootCommand

args_test.go:198–297  ·  args_test.go::TestArgumentsRootCommand
(t *testing.T)

Source from the content-addressed store, hash-verified

196}
197
198func TestArgumentsRootCommand(t *testing.T) {
199 tests := []struct {
200 name string
201 args []string
202 expectedIvals []int
203 expectedUivals []uint
204 expectedFvals []float64
205 errStr string
206 }{
207 {
208 name: "set ival",
209 args: []string{"foo", "10"},
210 expectedIvals: []int{10},
211 expectedUivals: []uint{},
212 expectedFvals: []float64{},
213 },
214 {
215 name: "set invalid ival",
216 args: []string{"foo", "10.0"},
217 expectedIvals: []int{},
218 expectedUivals: []uint{},
219 expectedFvals: []float64{},
220 errStr: "strconv.ParseInt: parsing \"10.0\": invalid syntax",
221 },
222 {
223 name: "set ival uival",
224 args: []string{"foo", "-10", "11"},
225 expectedIvals: []int{-10},
226 expectedUivals: []uint{11},
227 expectedFvals: []float64{},
228 },
229 {
230 name: "set ival uival fval",
231 args: []string{"foo", "-12", "14", "10.1"},
232 expectedIvals: []int{-12},
233 expectedUivals: []uint{14},
234 expectedFvals: []float64{10.1},
235 },
236 {
237 name: "set ival uival multu fvals",
238 args: []string{"foo", "-13", "12", "10.1", "11.09"},
239 expectedIvals: []int{-13},
240 expectedUivals: []uint{12},
241 expectedFvals: []float64{10.1, 11.09},
242 },
243 {
244 name: "set fvals beyond max",
245 args: []string{"foo", "13", "10", "10.1", "11.09", "12.1"},
246 expectedIvals: []int{13},
247 expectedUivals: []uint{10},
248 expectedFvals: []float64{10.1, 11.09},
249 errStr: "No help topic for '12.1'",
250 },
251 }
252
253 for _, test := range tests {
254 t.Run(test.name, func(t *testing.T) {
255 cmd := buildMinimalTestCommand()

Callers

nothing calls this directly

Calls 6

buildMinimalTestCommandFunction · 0.85
buildTestContextFunction · 0.85
IntArgsMethod · 0.80
FloatArgsMethod · 0.80
UintArgsMethod · 0.80
RunMethod · 0.45

Tested by

no test coverage detected