LUCENE-6697: test bug: the stupid-simple-yet-hopefully-bug-free numeric range filter was buggy

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1693800 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2015-08-02 09:45:18 +00:00
parent 2e077c1516
commit 0efca23e6e
1 changed files with 15 additions and 8 deletions

View File

@ -402,6 +402,9 @@ public class TestRangeTree extends LuceneTestCase {
}
}
if (random().nextBoolean()) {
if (VERBOSE) {
System.out.println(" forceMerge(1)");
}
w.forceMerge(1);
}
final IndexReader r = DirectoryReader.open(w, true);
@ -514,16 +517,20 @@ public class TestRangeTree extends LuceneTestCase {
}
private static boolean matches(long lower, boolean includeLower, long upper, boolean includeUpper, long value) {
if (value > lower && value < upper) {
return true;
if (includeLower == false) {
if (lower == Long.MAX_VALUE) {
return false;
}
lower++;
}
if (value == lower && includeLower) {
return true;
if (includeUpper == false) {
if (upper == Long.MIN_VALUE) {
return false;
}
upper--;
}
if (value == upper && includeUpper) {
return true;
}
return false;
return value >= lower && value <= upper;
}
private static long randomValue() {