Apache Lucene open-source search software
LUCENE-6270: Fix test bug.
Adrien Grandbf83ae2a449d
diff --git a/lucene/queries/src/test/org/apache/lucene/queries/TermsQueryTest.java b/lucene/queries/src/test/org/apache/lucene/queries/TermsQueryTest.javaindex 63f49de9f38..32570ca948a 100644--- a/lucene/queries/src/test/org/apache/lucene/queries/TermsQueryTest.java+++ b/lucene/queries/src/test/org/apache/lucene/queries/TermsQueryTest.java@@ -69,7 +69,7 @@ public class TermsQueryTest extends LuceneTestCase {doc.add(new StringField(term.field(), term.text(), Store.NO));iw.addDocument(doc);}- if (random().nextBoolean()) {+ if (numTerms > 1 && random().nextBoolean()) {iw.deleteDocuments(new TermQuery(allTerms.get(0)));}iw.commit();@@ -77,6 +77,11 @@ public class TermsQueryTest extends LuceneTestCase {final IndexSearcher searcher = newSearcher(reader);iw.close();+ if (reader.numDocs() == 0) {+ // may occasionally happen if all documents got the same term+ continue;+ }+for (int i = 0; i < 100; ++i) {final float boost = random().nextFloat() * 10;final int numQueryTerms = TestUtil.nextInt(random(), 1, 1 << TestUtil.nextInt(random(), 1, 8));