@@ -35,35 +35,51 @@ func TestValToInt(t *testing.T) {
35
35
is .Eq (2 , MustInt (in ))
36
36
}
37
37
38
+ // To int64
39
+ i64Val , err := ToInt64 ("2" )
40
+ is .Nil (err )
41
+ is .Eq (int64 (2 ), i64Val )
42
+
43
+ i64Val , err = Int64 ("-2" )
44
+ is .Nil (err )
45
+ is .Eq (int64 (- 2 ), i64Val )
46
+
47
+ is .Eq (int64 (0 ), MustInt64 ("2a" ))
48
+ is .Eq (int64 (0 ), MustInt64 (nil ))
49
+ for _ , in := range tests {
50
+ is .Eq (int64 (2 ), MustInt64 (in ))
51
+ }
52
+
38
53
// To uint
39
54
uintVal , err := Uint ("2" )
40
55
is .Nil (err )
41
- is .Eq (uint64 (2 ), uintVal )
56
+ is .Eq (uint (2 ), uintVal )
42
57
43
58
_ , err = ToUint ("-2" )
44
59
is .Err (err )
45
60
46
- is .Eq (uint64 (0 ), MustUint ("-2" ))
47
- is .Eq (uint64 (0 ), MustUint ("2a" ))
48
- is .Eq (uint64 (0 ), MustUint (nil ))
61
+ is .Eq (uint (0 ), MustUint ("-2" ))
62
+ is .Eq (uint (0 ), MustUint ("2a" ))
63
+ is .Eq (uint (0 ), MustUint (nil ))
49
64
for _ , in := range tests {
50
- is .Eq (uint64 (2 ), MustUint (in ))
65
+ is .Eq (uint (2 ), MustUint (in ))
51
66
}
52
67
53
- // To int64
54
- i64Val , err := ToInt64 ("2" )
68
+ // To uint64
69
+ u64 , err := Uint64 ("2" )
55
70
is .Nil (err )
56
- is .Eq (int64 (2 ), i64Val )
71
+ is .Eq (uint64 (2 ), u64 )
57
72
58
- i64Val , err = Int64 ("-2" )
59
- is .Nil (err )
60
- is .Eq (int64 (- 2 ), i64Val )
73
+ _ , err = ToUint64 ("-2" )
74
+ is .Err (err )
61
75
62
- is .Eq (int64 (0 ), MustInt64 ("2a" ))
63
- is .Eq (int64 (0 ), MustInt64 (nil ))
76
+ is .Eq (uint64 (0 ), MustUint64 ("-2" ))
77
+ is .Eq (uint64 (0 ), MustUint64 ("2a" ))
78
+ is .Eq (uint64 (0 ), MustUint64 (nil ))
64
79
for _ , in := range tests {
65
- is .Eq (int64 (2 ), MustInt64 (in ))
80
+ is .Eq (uint64 (2 ), MustUint64 (in ))
66
81
}
82
+
67
83
}
68
84
69
85
func TestValToStr (t * testing.T ) {
@@ -277,16 +293,16 @@ func TestEscape(t *testing.T) {
277
293
func TestStrToTime (t * testing.T ) {
278
294
is := assert .New (t )
279
295
tests := map [string ]string {
280
- "20180927" : "2018-09-27 00:00:00 +0000 UTC " ,
281
- "2018-09-27" : "2018-09-27 00:00:00 +0000 UTC " ,
282
- "2018-09-27 12" : "2018-09-27 12:00:00 +0000 UTC " ,
283
- "2018-09-27T12" : "2018-09-27 12:00:00 +0000 UTC " ,
284
- "2018-09-27 12:34" : "2018-09-27 12:34:00 +0000 UTC " ,
285
- "2018-09-27T12:34" : "2018-09-27 12:34:00 +0000 UTC " ,
286
- "2018-09-27 12:34:45" : "2018-09-27 12:34:45 +0000 UTC " ,
287
- "2018-09-27T12:34:45" : "2018-09-27 12:34:45 +0000 UTC " ,
288
- "2018/09/27 12:34:45" : "2018-09-27 12:34:45 +0000 UTC " ,
289
- "2018/09/27T12:34:45Z" : "2018-09-27 12:34:45 +0000 UTC " ,
296
+ "20180927" : "2018-09-27 00:00:00 +0800 CST " ,
297
+ "2018-09-27" : "2018-09-27 00:00:00 +0800 CST " ,
298
+ "2018-09-27 12" : "2018-09-27 12:00:00 +0800 CST " ,
299
+ "2018-09-27T12" : "2018-09-27 12:00:00 +0800 CST " ,
300
+ "2018-09-27 12:34" : "2018-09-27 12:34:00 +0800 CST " ,
301
+ "2018-09-27T12:34" : "2018-09-27 12:34:00 +0800 CST " ,
302
+ "2018-09-27 12:34:45" : "2018-09-27 12:34:45 +0800 CST " ,
303
+ "2018-09-27T12:34:45" : "2018-09-27 12:34:45 +0800 CST " ,
304
+ "2018/09/27 12:34:45" : "2018-09-27 12:34:45 +0800 CST " ,
305
+ "2018/09/27T12:34:45Z" : "2018-09-27 12:34:45 +0800 CST " ,
290
306
}
291
307
292
308
for sample , want := range tests {
0 commit comments