2021-02-01 00:10:16 +01:00
|
|
|
package prometheus
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestInRange(t *testing.T) {
|
2024-07-12 08:59:31 +02:00
|
|
|
f := func(filterMin, filterMax, blockMin, blockMax int64, resultExpected bool) {
|
|
|
|
t.Helper()
|
|
|
|
|
2021-02-01 00:10:16 +01:00
|
|
|
f := filter{
|
2024-07-12 08:59:31 +02:00
|
|
|
min: filterMin,
|
|
|
|
max: filterMax,
|
2021-02-01 00:10:16 +01:00
|
|
|
}
|
2024-07-12 08:59:31 +02:00
|
|
|
result := f.inRange(blockMin, blockMax)
|
|
|
|
if result != resultExpected {
|
|
|
|
t.Fatalf("unexpected result; got %v; want %v", result, resultExpected)
|
2021-02-01 00:10:16 +01:00
|
|
|
}
|
|
|
|
}
|
2024-07-12 08:59:31 +02: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-02-01 00:10:16 +01:00
|
|
|
}
|