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

Function TestArgsFloatTypes

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

Source from the content-addressed store, hash-verified

46}
47
48func TestArgsFloatTypes(t *testing.T) {
49 cmd := buildMinimalTestCommand()
50 var fval float64
51 cmd.Arguments = []Argument{
52 &FloatArg{
53 Name: "ia",
54 Destination: &fval,
55 },
56 }
57
58 err := cmd.Run(buildTestContext(t), []string{"foo", "10"})
59 r := require.New(t)
60 r.NoError(err)
61 r.Equal(float64(10), fval)
62 r.Equal(float64(10), cmd.FloatArg("ia"))
63 r.Equal(float64(10), cmd.Float64Arg("ia"))
64 r.Equal(float32(0), cmd.Float32Arg("ia"))
65 r.Equal(float64(0), cmd.FloatArg("iab"))
66 r.Equal(int8(0), cmd.Int8Arg("ia"))
67 r.Equal(int16(0), cmd.Int16Arg("ia"))
68 r.Equal(int32(0), cmd.Int32Arg("ia"))
69 r.Equal(int64(0), cmd.Int64Arg("ia"))
70 r.Empty(cmd.StringArg("ia"))
71
72 r.Error(cmd.Run(buildTestContext(t), []string{"foo", "a"}))
73}
74
75func TestArgsIntTypes(t *testing.T) {
76 cmd := buildMinimalTestCommand()

Callers

nothing calls this directly

Calls 12

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