fix(pkg): fix using ~ as the lower bound for RangeMinMax

This commit is contained in:
Emmanuel BENOîT 2024-07-20 20:33:15 +02:00
parent ee05d6f004
commit 1f9be057b6
Signed by: Emmanuel BENOîT
SSH key fingerprint: SHA256:l7PFUUF5TCDsvYeQC9OnTNz08dFY7Fvf4Hv3neIqYpg
2 changed files with 11 additions and 0 deletions

View file

@ -35,6 +35,9 @@ func RangeMinMax(min, max string) *Range {
panic("invalid performance data range minimum value") panic("invalid performance data range minimum value")
} }
pdRange := &Range{} pdRange := &Range{}
if min == "~" {
min = ""
}
pdRange.start = min pdRange.start = min
pdRange.end = max pdRange.end = max
return pdRange return pdRange

View file

@ -43,6 +43,14 @@ func TestRangeMinMax(t *testing.T) {
assert.False(t, pdr.inside, "Inside flag should not be set") assert.False(t, pdr.inside, "Inside flag should not be set")
} }
func TestRangeMinMaxOpen(t *testing.T) {
min, max := "~", "456"
pdr := RangeMinMax(min, max)
assert.Equal(t, "", pdr.start, "Min value not clear in PerfDataRange")
assert.Equal(t, max, pdr.end, "Max value not copied to PerfDataRange")
assert.False(t, pdr.inside, "Inside flag should not be set")
}
func TestRangeInside(t *testing.T) { func TestRangeInside(t *testing.T) {
pdr := &Range{} pdr := &Range{}
pdr = pdr.Inside() pdr = pdr.Inside()