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

Function TestArgsIntTypes

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

Source from the content-addressed store, hash-verified

73}
74
75func TestArgsIntTypes(t *testing.T) {
76 cmd := buildMinimalTestCommand()
77 var ival int
78 cmd.Arguments = []Argument{
79 &IntArg{
80 Name: "ia",
81 Destination: &ival,
82 },
83 }
84
85 err := cmd.Run(buildTestContext(t), []string{"foo", "10"})
86 r := require.New(t)
87 r.NoError(err)
88 r.Equal(10, ival)
89 r.Equal(10, cmd.IntArg("ia"))
90 r.Equal(0, cmd.IntArg("iab"))
91 r.Equal(int8(0), cmd.Int8Arg("ia"))
92 r.Equal(int16(0), cmd.Int16Arg("ia"))
93 r.Equal(int32(0), cmd.Int32Arg("ia"))
94 r.Equal(int64(0), cmd.Int64Arg("ia"))
95 r.Equal(float64(0), cmd.FloatArg("ia"))
96 r.Empty(cmd.StringArg("ia"))
97
98 r.Error(cmd.Run(buildTestContext(t), []string{"foo", "10.0"}))
99}
100
101func TestArgsFloatSliceTypes(t *testing.T) {
102 cmd := buildMinimalTestCommand()

Callers

nothing calls this directly

Calls 11

buildMinimalTestCommandFunction · 0.85
buildTestContextFunction · 0.85
IntArgMethod · 0.80
Int8ArgMethod · 0.80
Int16ArgMethod · 0.80
Int32ArgMethod · 0.80
Int64ArgMethod · 0.80
FloatArgMethod · 0.80
StringArgMethod · 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…