Accept values with a negative exponent in wavefront parser (#5462)
This commit is contained in:
parent
33dfbfdf5e
commit
5f1bc9e49f
|
@ -60,7 +60,7 @@ func (ep *ValueParser) parse(p *PointParser, pt *Point) error {
|
||||||
tok, lit = p.scan()
|
tok, lit = p.scan()
|
||||||
}
|
}
|
||||||
|
|
||||||
for tok != EOF && (tok == LETTER || tok == NUMBER || tok == DOT) {
|
for tok != EOF && (tok == LETTER || tok == NUMBER || tok == DOT || tok == MINUS_SIGN) {
|
||||||
p.writeBuf.WriteString(lit)
|
p.writeBuf.WriteString(lit)
|
||||||
tok, lit = p.scan()
|
tok, lit = p.scan()
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,24 @@ func TestParse(t *testing.T) {
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.EqualValues(t, parsedMetrics[0], testMetric)
|
assert.EqualValues(t, parsedMetrics[0], testMetric)
|
||||||
|
|
||||||
|
parsedMetrics, err = parser.Parse([]byte("\"test.metric\" -1.1234 1530939936 \"source\"=\"mysource\" tag2=value2"))
|
||||||
|
assert.NoError(t, err)
|
||||||
|
testMetric, err = metric.New("test.metric", map[string]string{"source": "mysource", "tag2": "value2"}, map[string]interface{}{"value": -1.1234}, time.Unix(1530939936, 0))
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.EqualValues(t, parsedMetrics[0], testMetric)
|
||||||
|
|
||||||
|
parsedMetrics, err = parser.Parse([]byte("\"test.metric\" 1.1234e04 1530939936 \"source\"=\"mysource\" tag2=value2"))
|
||||||
|
assert.NoError(t, err)
|
||||||
|
testMetric, err = metric.New("test.metric", map[string]string{"source": "mysource", "tag2": "value2"}, map[string]interface{}{"value": 1.1234e04}, time.Unix(1530939936, 0))
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.EqualValues(t, parsedMetrics[0], testMetric)
|
||||||
|
|
||||||
|
parsedMetrics, err = parser.Parse([]byte("\"test.metric\" 1.1234e-04 1530939936 \"source\"=\"mysource\" tag2=value2"))
|
||||||
|
assert.NoError(t, err)
|
||||||
|
testMetric, err = metric.New("test.metric", map[string]string{"source": "mysource", "tag2": "value2"}, map[string]interface{}{"value": 1.1234e-04}, time.Unix(1530939936, 0))
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.EqualValues(t, parsedMetrics[0], testMetric)
|
||||||
|
|
||||||
parsedMetrics, err = parser.Parse([]byte("test.metric 1.1234 1530939936 source=\"mysource\" tag2=value2 "))
|
parsedMetrics, err = parser.Parse([]byte("test.metric 1.1234 1530939936 source=\"mysource\" tag2=value2 "))
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
testMetric, err = metric.New("test.metric", map[string]string{"source": "mysource", "tag2": "value2"}, map[string]interface{}{"value": 1.1234}, time.Unix(1530939936, 0))
|
testMetric, err = metric.New("test.metric", map[string]string{"source": "mysource", "tag2": "value2"}, map[string]interface{}{"value": 1.1234}, time.Unix(1530939936, 0))
|
||||||
|
@ -201,6 +219,9 @@ func TestParseInvalid(t *testing.T) {
|
||||||
_, err = parser.Parse([]byte("test.metric 1 1530939936 tag1=val\\\"ue1"))
|
_, err = parser.Parse([]byte("test.metric 1 1530939936 tag1=val\\\"ue1"))
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
|
|
||||||
|
_, err = parser.Parse([]byte("\"test.metric\" -1.12-34 1530939936 \"source\"=\"mysource\" tag2=value2"))
|
||||||
|
assert.Error(t, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestParseDefaultTags(t *testing.T) {
|
func TestParseDefaultTags(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue