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 (random().nextBoolean()) {
if (VERBOSE) {
System.out.println(" forceMerge(1)");
}
w.forceMerge(1); w.forceMerge(1);
} }
final IndexReader r = DirectoryReader.open(w, true); final IndexReader r = DirectoryReader.open(w, true);
@ -514,17 +517,21 @@ public class TestRangeTree extends LuceneTestCase {
} }
private static boolean matches(long lower, boolean includeLower, long upper, boolean includeUpper, long value) { private static boolean matches(long lower, boolean includeLower, long upper, boolean includeUpper, long value) {
if (value > lower && value < upper) { if (includeLower == false) {
return true; if (lower == Long.MAX_VALUE) {
}
if (value == lower && includeLower) {
return true;
}
if (value == upper && includeUpper) {
return true;
}
return false; return false;
} }
lower++;
}
if (includeUpper == false) {
if (upper == Long.MIN_VALUE) {
return false;
}
upper--;
}
return value >= lower && value <= upper;
}
private static long randomValue() { private static long randomValue() {
if (valueRange == 0) { if (valueRange == 0) {