| 1 | package cliscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ |
| 2 | |
| 3 | import ( |
| 4 | "flagscip-go gomod github.com/golang/go/src go1.22 flag/" |
| 5 | "ioscip-go gomod github.com/golang/go/src go1.22 io/" |
| 6 | "testingscip-go gomod github.com/golang/go/src go1.22 testing/" |
| 7 | |
| 8 | "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/" |
| 9 | "github.com/stretchr/testify/requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/" |
| 10 | ) |
| 11 | |
| 12 | func TestIntFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/TestIntFlag().(t *testingscip-go gomod github.com/golang/go/src go1.22 testing/.Tscip-go gomod github.com/golang/go/src go1.22 testing/T#) { |
| 13 | tests := []struct { |
| 14 | name string |
| 15 | flag Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag# |
| 16 | arguments []string |
| 17 | expectedValue int |
| 18 | expectErr bool |
| 19 | }{ |
| 20 | { |
| 21 | name: "valid", |
| 22 | flag: &IntFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/IntFlag#{ |
| 23 | Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Name.: "number", |
| 24 | Aliasesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Aliases.: []string{"n"}, |
| 25 | }, |
| 26 | arguments: []string{"--number", "-234567"}, |
| 27 | expectedValue: -234567, |
| 28 | }, |
| 29 | { |
| 30 | name: "invalid", |
| 31 | flag: &IntFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/IntFlag#{ |
| 32 | Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Name.: "number", |
| 33 | }, |
| 34 | arguments: []string{"--number", "gopher"}, |
| 35 | expectErr: true, |
| 36 | }, |
| 37 | } |
| 38 | |
| 39 | for _, tt := range tests { |
| 40 | 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#) { |
| 41 | cmd := &Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#{ |
| 42 | Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.: "mock", |
| 43 | 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}, |
| 44 | 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., |
| 45 | 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., |
| 46 | } |
| 47 | |
| 48 | 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...)) |
| 49 | |
| 50 | if tt.expectErr { |
| 51 | 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) |
| 52 | |
| 53 | return |
| 54 | } |
| 55 | |
| 56 | 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) |
| 57 | |
| 58 | for _, name := range tt.flag.Namesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#Names.() { |
| 59 | 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.Intscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Int().(name)) |
| 60 | } |
| 61 | }) |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | func TestInt8Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/TestInt8Flag().(t *testingscip-go gomod github.com/golang/go/src go1.22 testing/.Tscip-go gomod github.com/golang/go/src go1.22 testing/T#) { |
| 66 | tests := []struct { |
| 67 | name string |
| 68 | flag Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag# |
| 69 | arguments []string |
| 70 | expectedValue int8 |
| 71 | expectErr bool |
| 72 | }{ |
| 73 | { |
| 74 | name: "valid", |
| 75 | flag: &Int8Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Int8Flag#{ |
| 76 | Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Name.: "number", |
| 77 | Aliasesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Aliases.: []string{"n"}, |
| 78 | }, |
| 79 | arguments: []string{"--number", "127"}, |
| 80 | expectedValue: 127, |
| 81 | }, |
| 82 | { |
| 83 | name: "invalid", |
| 84 | flag: &Int8Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Int8Flag#{ |
| 85 | Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Name.: "number", |
| 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.Int8scip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Int8().(name)) |
| 113 | } |
| 114 | }) |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | func TestInt16Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/TestInt16Flag().(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 int16 |
| 124 | expectErr bool |
| 125 | }{ |
| 126 | { |
| 127 | name: "valid", |
| 128 | flag: &Int16Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Int16Flag#{ |
| 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", "32767"}, |
| 133 | expectedValue: 32767, |
| 134 | }, |
| 135 | { |
| 136 | name: "invalid", |
| 137 | flag: &Int16Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Int16Flag#{ |
| 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 | name: "out of range", |
| 145 | flag: &Int16Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Int16Flag#{ |
| 146 | Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Name.: "number", |
| 147 | }, |
| 148 | arguments: []string{"--number", "32768"}, |
| 149 | expectErr: true, |
| 150 | }, |
| 151 | } |
| 152 | |
| 153 | for _, tt := range tests { |
| 154 | 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#) { |
| 155 | cmd := &Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#{ |
| 156 | Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.: "mock", |
| 157 | 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}, |
| 158 | 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., |
| 159 | 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., |
| 160 | } |
| 161 | |
| 162 | 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...)) |
| 163 | |
| 164 | if tt.expectErr { |
| 165 | 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) |
| 166 | |
| 167 | return |
| 168 | } |
| 169 | |
| 170 | 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) |
| 171 | |
| 172 | for _, name := range tt.flag.Namesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#Names.() { |
| 173 | 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.Int16scip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Int16().(name)) |
| 174 | } |
| 175 | }) |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | func TestInt32Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/TestInt32Flag().(t *testingscip-go gomod github.com/golang/go/src go1.22 testing/.Tscip-go gomod github.com/golang/go/src go1.22 testing/T#) { |
| 180 | tests := []struct { |
| 181 | name string |
| 182 | flag Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag# |
| 183 | arguments []string |
| 184 | expectedValue int32 |
| 185 | expectErr bool |
| 186 | }{ |
| 187 | { |
| 188 | name: "valid", |
| 189 | flag: &Int32Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Int32Flag#{ |
| 190 | Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Name.: "number", |
| 191 | Aliasesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Aliases.: []string{"n"}, |
| 192 | }, |
| 193 | arguments: []string{"--number", "2147483647"}, |
| 194 | expectedValue: 2147483647, |
| 195 | }, |
| 196 | { |
| 197 | name: "invalid", |
| 198 | flag: &Int32Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Int32Flag#{ |
| 199 | Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Name.: "number", |
| 200 | }, |
| 201 | |
| 202 | arguments: []string{"--number", "gopher"}, |
| 203 | expectErr: true, |
| 204 | }, |
| 205 | { |
| 206 | name: "out of range", |
| 207 | flag: &Int32Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Int32Flag#{ |
| 208 | Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Name.: "number", |
| 209 | }, |
| 210 | arguments: []string{"--number", "2147483648"}, |
| 211 | expectErr: true, |
| 212 | }, |
| 213 | } |
| 214 | |
| 215 | for _, tt := range tests { |
| 216 | 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#) { |
| 217 | cmd := &Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#{ |
| 218 | Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.: "mock", |
| 219 | 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}, |
| 220 | 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., |
| 221 | 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., |
| 222 | } |
| 223 | |
| 224 | 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...)) |
| 225 | |
| 226 | if tt.expectErr { |
| 227 | 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) |
| 228 | |
| 229 | return |
| 230 | } |
| 231 | |
| 232 | 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) |
| 233 | |
| 234 | for _, name := range tt.flag.Namesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#Names.() { |
| 235 | 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.Int32scip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Int32().(name)) |
| 236 | } |
| 237 | }) |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | func TestInt64Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/TestInt64Flag().(t *testingscip-go gomod github.com/golang/go/src go1.22 testing/.Tscip-go gomod github.com/golang/go/src go1.22 testing/T#) { |
| 242 | tests := []struct { |
| 243 | name string |
| 244 | flag Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag# |
| 245 | arguments []string |
| 246 | expectedValue int64 |
| 247 | expectErr bool |
| 248 | }{ |
| 249 | { |
| 250 | name: "valid", |
| 251 | flag: &Int64Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Int64Flag#{ |
| 252 | Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Name.: "number", |
| 253 | Aliasesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Aliases.: []string{"n"}, |
| 254 | }, |
| 255 | arguments: []string{"--number", "-2147483648"}, |
| 256 | expectedValue: -2147483648, |
| 257 | }, |
| 258 | { |
| 259 | name: "invalid", |
| 260 | flag: &Int64Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Int64Flag#{ |
| 261 | Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Name.: "number", |
| 262 | }, |
| 263 | arguments: []string{"--number", "gopher"}, |
| 264 | expectErr: true, |
| 265 | }, |
| 266 | } |
| 267 | |
| 268 | for _, tt := range tests { |
| 269 | 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#) { |
| 270 | cmd := &Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#{ |
| 271 | Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.: "mock", |
| 272 | 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}, |
| 273 | 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., |
| 274 | 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., |
| 275 | } |
| 276 | |
| 277 | 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...)) |
| 278 | |
| 279 | if tt.expectErr { |
| 280 | 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) |
| 281 | |
| 282 | return |
| 283 | } |
| 284 | |
| 285 | 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) |
| 286 | |
| 287 | for _, name := range tt.flag.Namesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#Names.() { |
| 288 | 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.Int64scip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Int64().(name)) |
| 289 | } |
| 290 | }) |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | func TestIntFlagExtscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/TestIntFlagExt().(t *testingscip-go gomod github.com/golang/go/src go1.22 testing/.Tscip-go gomod github.com/golang/go/src go1.22 testing/T#) { |
| 295 | tests := []struct { |
| 296 | name string |
| 297 | flag *flagscip-go gomod github.com/golang/go/src go1.22 flag/.Flagscip-go gomod github.com/golang/go/src go1.22 flag/Flag# |
| 298 | config IntegerConfigscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/IntegerConfig# |
| 299 | arguments []string |
| 300 | flagName string |
| 301 | expectedValue string |
| 302 | expectErr bool |
| 303 | }{ |
| 304 | { |
| 305 | name: "valid", |
| 306 | flag: &flagscip-go gomod github.com/golang/go/src go1.22 flag/.Flagscip-go gomod github.com/golang/go/src go1.22 flag/Flag#{ |
| 307 | Namescip-go gomod github.com/golang/go/src go1.22 flag/Flag#Name.: "number", |
| 308 | }, |
| 309 | config: IntegerConfigscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/IntegerConfig#{}, |
| 310 | arguments: []string{"--number", "234567"}, |
| 311 | flagName: "number", |
| 312 | expectedValue: "234567", |
| 313 | }, |
| 314 | { |
| 315 | name: "valid", |
| 316 | flag: &flagscip-go gomod github.com/golang/go/src go1.22 flag/.Flagscip-go gomod github.com/golang/go/src go1.22 flag/Flag#{ |
| 317 | Namescip-go gomod github.com/golang/go/src go1.22 flag/Flag#Name.: "number", |
| 318 | }, |
| 319 | config: IntegerConfigscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/IntegerConfig#{Basescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/IntegerConfig#Base.: 10}, |
| 320 | arguments: []string{"--number", "234567"}, |
| 321 | flagName: "number", |
| 322 | expectedValue: "234567", |
| 323 | }, |
| 324 | { |
| 325 | name: "valid hex", |
| 326 | flag: &flagscip-go gomod github.com/golang/go/src go1.22 flag/.Flagscip-go gomod github.com/golang/go/src go1.22 flag/Flag#{ |
| 327 | Namescip-go gomod github.com/golang/go/src go1.22 flag/Flag#Name.: "number", |
| 328 | DefValuescip-go gomod github.com/golang/go/src go1.22 flag/Flag#DefValue.: "FFFF", |
| 329 | }, |
| 330 | config: IntegerConfigscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/IntegerConfig#{Basescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/IntegerConfig#Base.: 16}, |
| 331 | arguments: []string{"--number", "39447"}, |
| 332 | flagName: "number", |
| 333 | expectedValue: "39447", |
| 334 | }, |
| 335 | { |
| 336 | name: "valid hex default", |
| 337 | flag: &flagscip-go gomod github.com/golang/go/src go1.22 flag/.Flagscip-go gomod github.com/golang/go/src go1.22 flag/Flag#{ |
| 338 | Namescip-go gomod github.com/golang/go/src go1.22 flag/Flag#Name.: "number", |
| 339 | DefValuescip-go gomod github.com/golang/go/src go1.22 flag/Flag#DefValue.: "FFFF", |
| 340 | }, |
| 341 | config: IntegerConfigscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/IntegerConfig#{Basescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/IntegerConfig#Base.: 16}, |
| 342 | expectedValue: "ffff", |
| 343 | }, |
| 344 | { |
| 345 | name: "invalid", |
| 346 | flag: &flagscip-go gomod github.com/golang/go/src go1.22 flag/.Flagscip-go gomod github.com/golang/go/src go1.22 flag/Flag#{ |
| 347 | Namescip-go gomod github.com/golang/go/src go1.22 flag/Flag#Name.: "number", |
| 348 | }, |
| 349 | arguments: []string{"--number", "gopher"}, |
| 350 | expectErr: true, |
| 351 | }, |
| 352 | } |
| 353 | |
| 354 | for _, tt := range tests { |
| 355 | 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#) { |
| 356 | var uValue intValuescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/intValue#[int] |
| 357 | var u int |
| 358 | |
| 359 | f := &extFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/extFlag#{fscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/extFlag#f.: tt.flag} |
| 360 | |
| 361 | tt.flag.Valuescip-go gomod github.com/golang/go/src go1.22 flag/Flag#Value. = uValue.Createscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/intValue#Create().(u, &u, tt.config) |
| 362 | |
| 363 | if tt.config.Basescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/IntegerConfig#Base. != 0 && tt.config.Basescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/IntegerConfig#Base. != 10 { |
| 364 | t.Skipfscip-go gomod github.com/golang/go/src go1.22 testing/common#Skipf().("skipping %q with base %d, only base 10 is supported", tt.name, tt.config.Basescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/IntegerConfig#Base.) |
| 365 | } |
| 366 | |
| 367 | cmd := &Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#{ |
| 368 | Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.: "mock", |
| 369 | 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#{f}, |
| 370 | 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., |
| 371 | 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., |
| 372 | } |
| 373 | |
| 374 | 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...)) |
| 375 | |
| 376 | if tt.expectErr { |
| 377 | 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) |
| 378 | |
| 379 | return |
| 380 | } |
| 381 | |
| 382 | 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) |
| 383 | |
| 384 | 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, f.GetValuescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/extFlag#GetValue().()) |
| 385 | }) |
| 386 | } |
| 387 | } |