push
386 of 386 new or added lines in 11 files covered. (100.0%)
1932 of 2174 relevant lines covered (88.87%)
98805.34 hits per line
1 |
package util
|
|
2 |
|
|
3 |
func IsNumber(v interface{}) bool { |
1,762,994✔ |
4 |
switch v.(type) { |
1,762,994✔ |
5 |
case int, uint, uint8, uint16, uint32, uint64, |
|
6 |
int8, int16, int32, int64, float32, float64: |
989,221✔ |
7 |
return true |
989,221✔ |
8 |
default:
|
773,773✔ |
9 |
return false |
773,773✔ |
10 |
} |
|
11 |
} |
|
12 |
|
|
13 |
func ToFloat64(v interface{}) float64 { |
384,958✔ |
14 |
switch vType := v.(type) { |
384,958✔ |
|
case uint32: |
× |
|
return float64(vType) |
× |
17 |
case uint64: |
1✔ |
18 |
return float64(vType) |
1✔ |
19 |
case int64: |
87,815✔ |
20 |
return float64(vType) |
87,815✔ |
21 |
case float64: |
297,142✔ |
22 |
return vType
|
297,142✔ |
23 |
} |
|
24 |
panic("not a number") |
× |
25 |
} |
|
26 |
|
|
27 |
func ToInt64(v interface{}) int64 { |
60,148✔ |
28 |
switch vType := v.(type) { |
60,148✔ |
29 |
case uint64: |
1,001✔ |
30 |
return int64(vType) |
1,001✔ |
31 |
case int64: |
59,147✔ |
32 |
return vType
|
59,147✔ |
33 |
} |
|
34 |
panic("not a number") |
× |
35 |
} |
|
36 |
|
|
37 |
func BoolToInt(v bool) int { |
9,994✔ |
38 |
if v {
|
15,043✔ |
39 |
return 1 |
5,049✔ |
40 |
} |
5,049✔ |
41 |
return 0 |
4,945✔ |
42 |
} |