@@ -13,11 +13,13 @@ import (
13
13
)
14
14
15
15
type defaultOptions struct {
16
- Int int `long:"i"`
17
- IntDefault int `long:"id" default:"1"`
16
+ Int int `long:"i"`
17
+ IntDefault int `long:"id" default:"1"`
18
+ IntUnderscore int `long:"idu" default:"1_0"`
18
19
19
- Float64 float64 `long:"f"`
20
- Float64Default float64 `long:"fd" default:"-3.14"`
20
+ Float64 float64 `long:"f"`
21
+ Float64Default float64 `long:"fd" default:"-3.14"`
22
+ Float64Underscore float64 `long:"fdu" default:"-3_3.14"`
21
23
22
24
NumericFlag bool `short:"3"`
23
25
@@ -46,11 +48,13 @@ func TestDefaults(t *testing.T) {
46
48
msg : "no arguments, expecting default values" ,
47
49
args : []string {},
48
50
expected : defaultOptions {
49
- Int : 0 ,
50
- IntDefault : 1 ,
51
+ Int : 0 ,
52
+ IntDefault : 1 ,
53
+ IntUnderscore : 10 ,
51
54
52
- Float64 : 0.0 ,
53
- Float64Default : - 3.14 ,
55
+ Float64 : 0.0 ,
56
+ Float64Default : - 3.14 ,
57
+ Float64Underscore : - 33.14 ,
54
58
55
59
NumericFlag : false ,
56
60
@@ -69,13 +73,15 @@ func TestDefaults(t *testing.T) {
69
73
},
70
74
{
71
75
msg : "non-zero value arguments, expecting overwritten arguments" ,
72
- args : []string {"--i=3" , "--id=3" , "--f=-2.71" , "--fd=2.71" , "-3" , "--str=def" , "--strd=def" , "--t=3ms" , "--td=3ms" , "--m=c:3" , "--md=c:3" , "--s=3" , "--sd=3" },
76
+ args : []string {"--i=3" , "--id=3" , "--idu=3_3" , "-- f=-2.71" , "--fd=2.71" , "--fdu=2_2 .71" , "-3" , "--str=def" , "--strd=def" , "--t=3ms" , "--td=3ms" , "--m=c:3" , "--md=c:3" , "--s=3" , "--sd=3" },
73
77
expected : defaultOptions {
74
- Int : 3 ,
75
- IntDefault : 3 ,
78
+ Int : 3 ,
79
+ IntDefault : 3 ,
80
+ IntUnderscore : 33 ,
76
81
77
- Float64 : - 2.71 ,
78
- Float64Default : 2.71 ,
82
+ Float64 : - 2.71 ,
83
+ Float64Default : 2.71 ,
84
+ Float64Underscore : 22.71 ,
79
85
80
86
NumericFlag : true ,
81
87
@@ -99,13 +105,15 @@ func TestDefaults(t *testing.T) {
99
105
},
100
106
{
101
107
msg : "zero value arguments, expecting overwritten arguments" ,
102
- args : []string {"--i=0" , "--id=0" , "--f=0" , "--fd=0" , "--str" , "" , "--strd=\" \" " , "--t=0ms" , "--td=0s" , "--m=:0" , "--md=:0" , "--s=0" , "--sd=0" },
108
+ args : []string {"--i=0" , "--id=0" , "--idu=0" , "-- f=0" , "--fd=0" , "--fdu =0" , "--str" , "" , "--strd=\" \" " , "--t=0ms" , "--td=0s" , "--m=:0" , "--md=:0" , "--s=0" , "--sd=0" },
103
109
expected : defaultOptions {
104
- Int : 0 ,
105
- IntDefault : 0 ,
110
+ Int : 0 ,
111
+ IntDefault : 0 ,
112
+ IntUnderscore : 0 ,
106
113
107
- Float64 : 0 ,
108
- Float64Default : 0 ,
114
+ Float64 : 0 ,
115
+ Float64Default : 0 ,
116
+ Float64Underscore : 0 ,
109
117
110
118
String : "" ,
111
119
StringDefault : "" ,
0 commit comments