Merge pull request #277 from seebs/between

Return empty rows for impossible ranges
This commit is contained in:
seebs 2020-04-10 16:21:09 -05:00 committed by GitHub
commit 4325d62fe7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View file

@ -2233,7 +2233,7 @@ func (b *bsiGroup) baseValue(op pql.Token, value int64) (baseValue int64, outOfR
// baseValueBetween adjusts the min/max value to align with the range for Field.
func (b *bsiGroup) baseValueBetween(lo, hi int64) (baseValueLo, baseValueHi int64, outOfRange bool) {
min, max := b.bitDepthMin(), b.bitDepthMax()
if hi < min || lo > max {
if hi < min || lo > max || hi < lo {
return 0, 0, true
}

View file

@ -144,6 +144,7 @@ func TestBSIGroup_BaseValue(t *testing.T) {
{b1, 5, 20, 5, 20, false},
{b1, 20, 1005, 20, 255, false},
{b1, 1005, 2000, 0, 0, true},
{b1, 0, -1, 0, 0, true},
{b2, 5, 95, -95, -5, false},
{b2, 95, 120, -5, 20, false},