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

Function TestArgsIntSliceTypes

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

Source from the content-addressed store, hash-verified

122}
123
124func TestArgsIntSliceTypes(t *testing.T) {
125 cmd := buildMinimalTestCommand()
126 var ival []int
127 cmd.Arguments = []Argument{
128 &IntArgs{
129 Name: "ia",
130 Min: 1,
131 Max: -1,
132 Destination: &ival,
133 },
134 }
135
136 err := cmd.Run(buildTestContext(t), []string{"foo", "10", "20", "30"})
137 r := require.New(t)
138 r.NoError(err)
139 r.Equal([]int{10, 20, 30}, ival)
140 r.Equal([]int{10, 20, 30}, cmd.IntArgs("ia"))
141 r.Nil(cmd.Int8Args("ia"))
142 r.Nil(cmd.Int16Args("ia"))
143 r.Nil(cmd.Int32Args("ia"))
144 r.Nil(cmd.Int64Args("ia"))
145
146 r.Error(cmd.Run(buildTestContext(t), []string{"foo", "10", "20.0"}))
147}
148
149func TestArgsUintTypes(t *testing.T) {
150 cmd := buildMinimalTestCommand()

Callers

nothing calls this directly

Calls 9

buildMinimalTestCommandFunction · 0.85
buildTestContextFunction · 0.85
IntArgsMethod · 0.80
Int8ArgsMethod · 0.80
Int16ArgsMethod · 0.80
Int32ArgsMethod · 0.80
Int64ArgsMethod · 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…