| 1 | package cliscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ |
| 2 | |
| 3 | import ( |
| 4 | "ioscip-go gomod github.com/golang/go/src go1.22 io/" |
| 5 | "testingscip-go gomod github.com/golang/go/src go1.22 testing/" |
| 6 | |
| 7 | "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/" |
| 8 | "github.com/stretchr/testify/requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/" |
| 9 | ) |
| 10 | |
| 11 | func Test_FloatFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Test_FloatFlag().(t *testingscip-go gomod github.com/golang/go/src go1.22 testing/.Tscip-go gomod github.com/golang/go/src go1.22 testing/T#) { |
| 12 | tests := []struct { |
| 13 | name string |
| 14 | flag Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag# |
| 15 | arguments []string |
| 16 | expectedValue float64 |
| 17 | expectErr bool |
| 18 | }{ |
| 19 | { |
| 20 | name: "valid", |
| 21 | flag: &FloatFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FloatFlag#{ |
| 22 | Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Name.: "number", |
| 23 | Aliasesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Aliases.: []string{"n"}, |
| 24 | }, |
| 25 | arguments: []string{"--number", "-234567"}, |
| 26 | expectedValue: -234567, |
| 27 | }, |
| 28 | { |
| 29 | name: "invalid", |
| 30 | flag: &FloatFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FloatFlag#{ |
| 31 | Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Name.: "number", |
| 32 | }, |
| 33 | arguments: []string{"--number", "gopher"}, |
| 34 | expectErr: true, |
| 35 | }, |
| 36 | } |
| 37 | |
| 38 | for _, tt := range tests { |
| 39 | t.Runscip-go gomod github.com/golang/go/src go1.22 testing/T#Run().(tt.name, func(t *testingscip-go gomod github.com/golang/go/src go1.22 testing/.Tscip-go gomod github.com/golang/go/src go1.22 testing/T#) { |
| 40 | cmd := &Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#{ |
| 41 | Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.: "mock", |
| 42 | Flagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Flags.: []Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#{tt.flag}, |
| 43 | Writerscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Writer.: ioscip-go gomod github.com/golang/go/src go1.22 io/.Discardscip-go gomod github.com/golang/go/src go1.22 io/Discard., |
| 44 | ErrWriterscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#ErrWriter.: ioscip-go gomod github.com/golang/go/src go1.22 io/.Discardscip-go gomod github.com/golang/go/src go1.22 io/Discard., |
| 45 | } |
| 46 | |
| 47 | err := cmd.Runscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Run().(buildTestContextscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/buildTestContext().(t), append([]string{"mock"}, tt.arguments...)) |
| 48 | |
| 49 | if tt.expectErr { |
| 50 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.Errorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/Error().(t, err) |
| 51 | |
| 52 | return |
| 53 | } |
| 54 | |
| 55 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 56 | |
| 57 | for _, name := range tt.flag.Namesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#Names.() { |
| 58 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, tt.expectedValue, cmd.Floatscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Float().(name)) |
| 59 | } |
| 60 | }) |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | func Test_Float32Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Test_Float32Flag().(t *testingscip-go gomod github.com/golang/go/src go1.22 testing/.Tscip-go gomod github.com/golang/go/src go1.22 testing/T#) { |
| 65 | tests := []struct { |
| 66 | name string |
| 67 | flag Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag# |
| 68 | arguments []string |
| 69 | expectedValue float32 |
| 70 | expectErr bool |
| 71 | }{ |
| 72 | { |
| 73 | name: "valid", |
| 74 | flag: &Float32Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Float32Flag#{ |
| 75 | Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Name.: "number", |
| 76 | Aliasesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Aliases.: []string{"n"}, |
| 77 | }, |
| 78 | arguments: []string{"--number", "2147483647"}, |
| 79 | expectedValue: 2147483647, |
| 80 | }, |
| 81 | { |
| 82 | name: "invalid", |
| 83 | flag: &Float32Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Float32Flag#{ |
| 84 | Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Name.: "number", |
| 85 | }, |
| 86 | |
| 87 | arguments: []string{"--number", "gopher"}, |
| 88 | expectErr: true, |
| 89 | }, |
| 90 | } |
| 91 | |
| 92 | for _, tt := range tests { |
| 93 | t.Runscip-go gomod github.com/golang/go/src go1.22 testing/T#Run().(tt.name, func(t *testingscip-go gomod github.com/golang/go/src go1.22 testing/.Tscip-go gomod github.com/golang/go/src go1.22 testing/T#) { |
| 94 | cmd := &Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#{ |
| 95 | Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.: "mock", |
| 96 | Flagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Flags.: []Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#{tt.flag}, |
| 97 | Writerscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Writer.: ioscip-go gomod github.com/golang/go/src go1.22 io/.Discardscip-go gomod github.com/golang/go/src go1.22 io/Discard., |
| 98 | ErrWriterscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#ErrWriter.: ioscip-go gomod github.com/golang/go/src go1.22 io/.Discardscip-go gomod github.com/golang/go/src go1.22 io/Discard., |
| 99 | } |
| 100 | |
| 101 | err := cmd.Runscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Run().(buildTestContextscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/buildTestContext().(t), append([]string{"mock"}, tt.arguments...)) |
| 102 | |
| 103 | if tt.expectErr { |
| 104 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.Errorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/Error().(t, err) |
| 105 | |
| 106 | return |
| 107 | } |
| 108 | |
| 109 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 110 | |
| 111 | for _, name := range tt.flag.Namesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#Names.() { |
| 112 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, tt.expectedValue, cmd.Float32scip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Float32().(name)) |
| 113 | } |
| 114 | }) |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | func Test_Float64Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Test_Float64Flag().(t *testingscip-go gomod github.com/golang/go/src go1.22 testing/.Tscip-go gomod github.com/golang/go/src go1.22 testing/T#) { |
| 119 | tests := []struct { |
| 120 | name string |
| 121 | flag Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag# |
| 122 | arguments []string |
| 123 | expectedValue float64 |
| 124 | expectErr bool |
| 125 | }{ |
| 126 | { |
| 127 | name: "valid", |
| 128 | flag: &Float64Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Float64Flag#{ |
| 129 | Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Name.: "number", |
| 130 | Aliasesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Aliases.: []string{"n"}, |
| 131 | }, |
| 132 | arguments: []string{"--number", "-2147483648"}, |
| 133 | expectedValue: -2147483648, |
| 134 | }, |
| 135 | { |
| 136 | name: "invalid", |
| 137 | flag: &Float64Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Float64Flag#{ |
| 138 | Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Name.: "number", |
| 139 | }, |
| 140 | arguments: []string{"--number", "gopher"}, |
| 141 | expectErr: true, |
| 142 | }, |
| 143 | } |
| 144 | |
| 145 | for _, tt := range tests { |
| 146 | t.Runscip-go gomod github.com/golang/go/src go1.22 testing/T#Run().(tt.name, func(t *testingscip-go gomod github.com/golang/go/src go1.22 testing/.Tscip-go gomod github.com/golang/go/src go1.22 testing/T#) { |
| 147 | cmd := &Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#{ |
| 148 | Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.: "mock", |
| 149 | Flagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Flags.: []Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#{tt.flag}, |
| 150 | Writerscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Writer.: ioscip-go gomod github.com/golang/go/src go1.22 io/.Discardscip-go gomod github.com/golang/go/src go1.22 io/Discard., |
| 151 | ErrWriterscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#ErrWriter.: ioscip-go gomod github.com/golang/go/src go1.22 io/.Discardscip-go gomod github.com/golang/go/src go1.22 io/Discard., |
| 152 | } |
| 153 | |
| 154 | err := cmd.Runscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Run().(buildTestContextscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/buildTestContext().(t), append([]string{"mock"}, tt.arguments...)) |
| 155 | |
| 156 | if tt.expectErr { |
| 157 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.Errorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/Error().(t, err) |
| 158 | |
| 159 | return |
| 160 | } |
| 161 | |
| 162 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 163 | |
| 164 | for _, name := range tt.flag.Namesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#Names.() { |
| 165 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, tt.expectedValue, cmd.Float64scip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Float64().(name)) |
| 166 | } |
| 167 | }) |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | func Test_floatValue_Stringscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Test_floatValue_String().(t *testingscip-go gomod github.com/golang/go/src go1.22 testing/.Tscip-go gomod github.com/golang/go/src go1.22 testing/T#) { |
| 172 | var f float64 = 100 |
| 173 | fv := floatValuescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/floatValue#[float64]{valscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/floatValue#val.: &f} |
| 174 | |
| 175 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, "100", fv.Stringscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/floatValue#String().()) |
| 176 | } |