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

Function TestCommand_UintSlice

flag_uint_slice_test.go:11–58  ·  flag_uint_slice_test.go::TestCommand_UintSlice
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestCommand_UintSlice(t *testing.T) {
12 tests := []struct {
13 name string
14 flag Flag
15 arguments []string
16 expect []uint
17 expectErr bool
18 }{
19 {
20 flag: &UintSliceFlag{
21 Name: "numbers",
22 },
23 arguments: []string{"--numbers", "1,2,3,4"},
24 expect: []uint{1, 2, 3, 4},
25 },
26 {
27 flag: &UintSliceFlag{
28 Name: "numbers",
29 },
30 arguments: []string{"--numbers", "1,2", "--numbers", "3,4"},
31 expect: []uint{1, 2, 3, 4},
32 },
33 }
34 for _, tt := range tests {
35 t.Run(tt.name, func(t *testing.T) {
36 cmd := &Command{
37 Name: "mock",
38 Flags: []Flag{tt.flag},
39 Writer: io.Discard,
40 ErrWriter: io.Discard,
41 }
42
43 err := cmd.Run(buildTestContext(t), append([]string{"mock"}, tt.arguments...))
44
45 if tt.expectErr {
46 require.Error(t, err)
47
48 return
49 }
50
51 require.NoError(t, err)
52
53 for _, name := range tt.flag.Names() {
54 assert.Equalf(t, tt.expect, cmd.UintSlice(name), "UintSlice(%v)", name)
55 }
56 })
57 }
58}
59
60func TestCommand_Uint8Slice(t *testing.T) {
61 tests := []struct {

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected