Fix conversion from string float to integer (#5518)

This commit is contained in:
Daniel Nelson
2019-03-04 12:35:57 -08:00
committed by GitHub
parent d09c213562
commit c0e0da7ef6
2 changed files with 43 additions and 19 deletions

View File

@@ -129,8 +129,8 @@ func TestConverter(t *testing.T) {
converter: &Converter{
Fields: &Conversion{
String: []string{"a"},
Integer: []string{"b"},
Unsigned: []string{"c"},
Integer: []string{"b", "b1", "b2"},
Unsigned: []string{"c", "c1", "c2"},
Boolean: []string{"d"},
Float: []string{"e"},
Tag: []string{"f"},
@@ -141,12 +141,16 @@ func TestConverter(t *testing.T) {
"cpu",
map[string]string{},
map[string]interface{}{
"a": "howdy",
"b": "42",
"c": "42",
"d": "true",
"e": "42.0",
"f": "foo",
"a": "howdy",
"b": "42",
"b1": "42.2",
"b2": "42.5",
"c": "42",
"c1": "42.2",
"c2": "42.5",
"d": "true",
"e": "42.0",
"f": "foo",
},
time.Unix(0, 0),
),
@@ -158,11 +162,15 @@ func TestConverter(t *testing.T) {
"f": "foo",
},
map[string]interface{}{
"a": "howdy",
"b": int64(42),
"c": uint64(42),
"d": true,
"e": 42.0,
"a": "howdy",
"b": int64(42),
"b1": int64(42),
"b2": int64(43),
"c": uint64(42),
"c1": uint64(42),
"c2": uint64(43),
"d": true,
"e": 42.0,
},
time.Unix(0, 0),
),