LUCENE-8030: fix buggy assert

This commit is contained in:
Robert Muir 2017-10-31 22:30:16 -04:00
parent 5633268a45
commit 875d45ff14
1 changed files with 5 additions and 3 deletions

View File

@ -23,6 +23,7 @@ import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.search.CollectionStatistics;
import org.apache.lucene.search.Explanation;
import org.apache.lucene.search.TermStatistics;
import org.apache.lucene.search.spans.Spans;
import org.apache.lucene.util.BytesRef;
/** wraps a similarity with checks for testing */
@ -114,10 +115,11 @@ public class AssertingSimilarity extends Similarity {
assert doc >= 0;
assert doc < context.reader().maxDoc();
// payload in bounds
assert start >= 0;
assert end >= start;
assert payload.isValid();
assert end <= payload.length;
// position range in bounds
assert start >= 0;
assert start != Spans.NO_MORE_POSITIONS;
assert end > start;
// result in bounds
float payloadFactor = delegateScorer.computePayloadFactor(doc, start, end, payload);
assert Float.isFinite(payloadFactor);