@@ -234,6 +234,15 @@ func TestIntApplyInputSourceMethodSet(t *testing.T) {
234
234
expect (t , 15 , c .Int ("test" ))
235
235
}
236
236
237
+ func TestIntApplyInputSourceMethodSetNegativeValue (t * testing.T ) {
238
+ c := runTest (t , testApplyInputSource {
239
+ Flag : NewIntFlag (& cli.IntFlag {Name : "test" }),
240
+ FlagName : "test" ,
241
+ MapValue : - 1 ,
242
+ })
243
+ expect (t , - 1 , c .Int ("test" ))
244
+ }
245
+
237
246
func TestIntApplyInputSourceMethodContextSet (t * testing.T ) {
238
247
c := runTest (t , testApplyInputSource {
239
248
Flag : NewIntFlag (& cli.IntFlag {Name : "test" }),
@@ -264,6 +273,15 @@ func TestDurationApplyInputSourceMethodSet(t *testing.T) {
264
273
expect (t , 30 * time .Second , c .Duration ("test" ))
265
274
}
266
275
276
+ func TestDurationApplyInputSourceMethodSetNegativeValue (t * testing.T ) {
277
+ c := runTest (t , testApplyInputSource {
278
+ Flag : NewDurationFlag (& cli.DurationFlag {Name : "test" }),
279
+ FlagName : "test" ,
280
+ MapValue : - 30 * time .Second ,
281
+ })
282
+ expect (t , - 30 * time .Second , c .Duration ("test" ))
283
+ }
284
+
267
285
func TestDurationApplyInputSourceMethodContextSet (t * testing.T ) {
268
286
c := runTest (t , testApplyInputSource {
269
287
Flag : NewDurationFlag (& cli.DurationFlag {Name : "test" }),
@@ -294,6 +312,24 @@ func TestFloat64ApplyInputSourceMethodSet(t *testing.T) {
294
312
expect (t , 1.3 , c .Float64 ("test" ))
295
313
}
296
314
315
+ func TestFloat64ApplyInputSourceMethodSetNegativeValue (t * testing.T ) {
316
+ c := runTest (t , testApplyInputSource {
317
+ Flag : NewFloat64Flag (& cli.Float64Flag {Name : "test" }),
318
+ FlagName : "test" ,
319
+ MapValue : - 1.3 ,
320
+ })
321
+ expect (t , - 1.3 , c .Float64 ("test" ))
322
+ }
323
+
324
+ func TestFloat64ApplyInputSourceMethodSetNegativeValueNotSet (t * testing.T ) {
325
+ c := runTest (t , testApplyInputSource {
326
+ Flag : NewFloat64Flag (& cli.Float64Flag {Name : "test1" }),
327
+ FlagName : "test1" ,
328
+ // dont set map value
329
+ })
330
+ expect (t , 0.0 , c .Float64 ("test1" ))
331
+ }
332
+
297
333
func TestFloat64ApplyInputSourceMethodContextSet (t * testing.T ) {
298
334
c := runTest (t , testApplyInputSource {
299
335
Flag : NewFloat64Flag (& cli.Float64Flag {Name : "test" }),
0 commit comments