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

Function TestCommand_Float32Slice

flag_float_slice_test.go:60–107  ·  flag_float_slice_test.go::TestCommand_Float32Slice
(t *testing.T)

Source from the content-addressed store, hash-verified

58}
59
60func 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
109func TestCommand_Float64Slice(t *testing.T) {
110 tests := []struct {

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected