mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-11 14:53:49 +00:00
742b1b5443
- Document the bugfix at docs/CHANGELOG.md - Filter out NaN values before sorting as suggested at https://github.com/VictoriaMetrics/VictoriaMetrics/pull/5509#discussion_r1447369218 - Revert unrelated changes in lib/filestream and lib/fs - Use simpler test at app/vmselect/promql/exec_test.go Updates https://github.com/VictoriaMetrics/VictoriaMetrics/pull/5509 Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5506
36 lines
916 B
Go
36 lines
916 B
Go
package promql
|
|
|
|
import (
|
|
"math"
|
|
"testing"
|
|
)
|
|
|
|
func TestModeNoNaNs(t *testing.T) {
|
|
f := func(prevValue float64, a []float64, expectedResult float64) {
|
|
t.Helper()
|
|
result := modeNoNaNs(prevValue, a)
|
|
if math.IsNaN(result) {
|
|
if !math.IsNaN(expectedResult) {
|
|
t.Fatalf("unexpected result; got %v; want %v", result, expectedResult)
|
|
}
|
|
return
|
|
}
|
|
if result != expectedResult {
|
|
t.Fatalf("unexpected result; got %v; want %v", result, expectedResult)
|
|
}
|
|
}
|
|
f(nan, nil, nan)
|
|
f(nan, []float64{123}, 123)
|
|
f(nan, []float64{1, 2, 3}, 1)
|
|
f(nan, []float64{1, 2, 2}, 2)
|
|
f(nan, []float64{1, 1, 2}, 1)
|
|
f(nan, []float64{1, 1, 1}, 1)
|
|
f(nan, []float64{1, 2, 2, 3}, 2)
|
|
f(nan, []float64{1, 1, 2, 2, 3, 3, 3}, 3)
|
|
f(1, []float64{2, 3, 4, 5}, 1)
|
|
f(1, []float64{2, 2}, 2)
|
|
f(1, []float64{2, 3, 3}, 3)
|
|
f(1, []float64{2, 4, 3, 4, 3, 4}, 4)
|
|
f(1, []float64{2, 3, 3, 4, 4}, 3)
|
|
f(1, []float64{4, 3, 2, 3, 4}, 3)
|
|
}
|