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

Function TestCommand_Float64Slice

flag_float_slice_test.go:109–156  ·  flag_float_slice_test.go::TestCommand_Float64Slice
(t *testing.T)

Source from the content-addressed store, hash-verified

107}
108
109func TestCommand_Float64Slice(t *testing.T) {
110 tests := []struct {
111 name string
112 flag Flag
113 arguments []string
114 expect []float64
115 expectErr bool
116 }{
117 {
118 flag: &Float64SliceFlag{
119 Name: "numbers",
120 },
121 arguments: []string{"--numbers", "1,2,3,4"},
122 expect: []float64{1, 2, 3, 4},
123 },
124 {
125 flag: &Float64SliceFlag{
126 Name: "numbers",
127 },
128 arguments: []string{"--numbers", "1,2", "--numbers", "3,4"},
129 expect: []float64{1, 2, 3, 4},
130 },
131 }
132 for _, tt := range tests {
133 t.Run(tt.name, func(t *testing.T) {
134 cmd := &Command{
135 Name: "mock",
136 Flags: []Flag{tt.flag},
137 Writer: io.Discard,
138 ErrWriter: io.Discard,
139 }
140
141 err := cmd.Run(buildTestContext(t), append([]string{"mock"}, tt.arguments...))
142
143 if tt.expectErr {
144 require.Error(t, err)
145
146 return
147 }
148
149 require.NoError(t, err)
150
151 for _, name := range tt.flag.Names() {
152 assert.Equalf(t, tt.expect, cmd.Float64Slice(name), "Float64Slice(%v)", name)
153 }
154 })
155 }
156}

Callers

nothing calls this directly

Calls 5

RunMethod · 0.95
Float64SliceMethod · 0.95
buildTestContextFunction · 0.85
NamesMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected