parent
335e4325d8
commit
c874e48406
|
@ -614,14 +614,11 @@ func scanNumber(buf []byte, i int) (int, error) {
|
|||
continue
|
||||
}
|
||||
|
||||
// NaN is a valid float
|
||||
// NaN is an unsupported value
|
||||
if i+2 < len(buf) && (buf[i] == 'N' || buf[i] == 'n') {
|
||||
if (buf[i+1] == 'a' || buf[i+1] == 'A') && (buf[i+2] == 'N' || buf[i+2] == 'n') {
|
||||
i += 3
|
||||
continue
|
||||
}
|
||||
return i, fmt.Errorf("invalid number")
|
||||
}
|
||||
|
||||
if !isNumeric(buf[i]) {
|
||||
return i, fmt.Errorf("invalid number")
|
||||
}
|
||||
|
|
|
@ -1097,36 +1097,21 @@ func TestNewPointLargeInteger(t *testing.T) {
|
|||
)
|
||||
}
|
||||
|
||||
func TestNewPointNaN(t *testing.T) {
|
||||
test(t, `cpu value=NaN 1000000000`,
|
||||
models.NewPoint(
|
||||
"cpu",
|
||||
models.Tags{},
|
||||
models.Fields{
|
||||
"value": math.NaN(),
|
||||
},
|
||||
time.Unix(1, 0)),
|
||||
)
|
||||
func TestParsePointNaN(t *testing.T) {
|
||||
_, err := models.ParsePointsString("cpu value=NaN 1000000000")
|
||||
if err == nil {
|
||||
t.Fatalf("ParsePoints expected error, got nil")
|
||||
}
|
||||
|
||||
test(t, `cpu value=nAn 1000000000`,
|
||||
models.NewPoint(
|
||||
"cpu",
|
||||
models.Tags{},
|
||||
models.Fields{
|
||||
"value": math.NaN(),
|
||||
},
|
||||
time.Unix(1, 0)),
|
||||
)
|
||||
_, err = models.ParsePointsString("cpu value=nAn 1000000000")
|
||||
if err == nil {
|
||||
t.Fatalf("ParsePoints expected error, got nil")
|
||||
}
|
||||
|
||||
test(t, `nan value=NaN`,
|
||||
models.NewPoint(
|
||||
"nan",
|
||||
models.Tags{},
|
||||
models.Fields{
|
||||
"value": math.NaN(),
|
||||
},
|
||||
time.Unix(0, 0)),
|
||||
)
|
||||
_, err = models.ParsePointsString("cpu value=NaN")
|
||||
if err == nil {
|
||||
t.Fatalf("ParsePoints expected error, got nil")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewPointLargeNumberOfTags(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue