Skip to content
Snippets Groups Projects
Unverified Commit a3500cc3 authored by Daniel Nelson's avatar Daniel Nelson Committed by GitHub
Browse files

Fix handling of floats with multiple leading zeroes (#4065)

parent bf0c59f5
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
......@@ -122,7 +122,7 @@ unsigned =
( digit | ( non_zero_digit digit* ) );
number =
( integer ( '.' digit* )? ) | ( '.' digit* );
'-'? (digit+ ('.' digit*)? | '.' digit+);
scientific =
number 'e'i ["\-+"]? digit+;
......
......@@ -517,6 +517,55 @@ var tests = []struct {
},
},
},
{
name: "float without integer digits negative",
input: []byte("cpu value=-.42"),
results: []Result{
Result{
Name: Measurement,
Value: []byte("cpu"),
},
Result{
Name: FieldKey,
Value: []byte("value"),
},
Result{
Name: FieldFloat,
Value: []byte("-.42"),
},
},
},
{
name: "float with multiple leading 0",
input: []byte("cpu value=00.42"),
results: []Result{
Result{
Name: Measurement,
Value: []byte("cpu"),
},
Result{
Name: FieldKey,
Value: []byte("value"),
},
Result{
Name: FieldFloat,
Value: []byte("00.42"),
},
},
},
{
name: "invalid float with only dot",
input: []byte("cpu value=."),
results: []Result{
Result{
Name: Measurement,
Value: []byte("cpu"),
},
Result{
err: ErrFieldParse,
},
},
},
{
name: "multiple fields",
input: []byte("cpu x=42,y=42"),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment