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

Function TestArgsFloatSliceTypes

args_test.go:101–122  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

99}
100
101func TestArgsFloatSliceTypes(t *testing.T) {
102 cmd := buildMinimalTestCommand()
103 var fval []float64
104 cmd.Arguments = []Argument{
105 &FloatArgs{
106 Name: "ia",
107 Min: 1,
108 Max: -1,
109 Destination: &fval,
110 },
111 }
112
113 err := cmd.Run(buildTestContext(t), []string{"foo", "10", "20", "30"})
114 r := require.New(t)
115 r.NoError(err)
116 r.Equal([]float64{10, 20, 30}, fval)
117 r.Equal([]float64{10, 20, 30}, cmd.FloatArgs("ia"))
118 r.Equal([]float64{10, 20, 30}, cmd.Float64Args("ia"))
119 r.Nil(cmd.Float32Args("ia"))
120
121 r.Error(cmd.Run(buildTestContext(t), []string{"foo", "10", "a"}))
122}
123
124func TestArgsIntSliceTypes(t *testing.T) {
125 cmd := buildMinimalTestCommand()

Callers

nothing calls this directly

Calls 7

buildMinimalTestCommandFunction · 0.85
buildTestContextFunction · 0.85
FloatArgsMethod · 0.80
Float64ArgsMethod · 0.80
Float32ArgsMethod · 0.80
RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…