2021-01-31 23:10:16 +00:00
|
|
|
package prometheus
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestInRange(t *testing.T) {
|
2024-07-12 06:59:31 +00:00
|
|
|
f := func(filterMin, filterMax, blockMin, blockMax int64, resultExpected bool) {
|
|
|
|
t.Helper()
|
|
|
|
|
2021-01-31 23:10:16 +00:00
|
|
|
f := filter{
|
2024-07-12 06:59:31 +00:00
|
|
|
min: filterMin,
|
|
|
|
max: filterMax,
|
2021-01-31 23:10:16 +00:00
|
|
|
}
|
2024-07-12 06:59:31 +00:00
|
|
|
result := f.inRange(blockMin, blockMax)
|
|
|
|
if result != resultExpected {
|
|
|
|
t.Fatalf("unexpected result; got %v; want %v", result, resultExpected)
|
2021-01-31 23:10:16 +00:00
|
|
|
}
|
|
|
|
}
|
2024-07-12 06:59:31 +00:00
|
|
|
|
|
|
|
f(0, 0, 1, 2, true)
|
|
|
|
f(0, 3, 1, 2, true)
|
|
|
|
f(0, 3, 4, 5, false)
|
|
|
|
f(3, 0, 1, 2, false)
|
|
|
|
f(3, 0, 2, 4, true)
|
|
|
|
f(3, 10, 1, 2, false)
|
|
|
|
f(3, 10, 1, 4, true)
|
|
|
|
f(3, 10, 5, 9, true)
|
|
|
|
f(3, 10, 9, 12, true)
|
|
|
|
f(3, 10, 12, 15, false)
|
2021-01-31 23:10:16 +00:00
|
|
|
}
|