From a5c6c6ddd679969318a572d5d4061f456abad17e Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Thu, 21 Nov 2013 15:50:47 +0000 Subject: [PATCH] Make sure there is at least one document when testing expression dictionary with deletes git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1544224 13f79535-47bb-0310-9956-ffa450edef68 --- .../search/suggest/DocumentExpressionDictionaryTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lucene/suggest/src/test/org/apache/lucene/search/suggest/DocumentExpressionDictionaryTest.java b/lucene/suggest/src/test/org/apache/lucene/search/suggest/DocumentExpressionDictionaryTest.java index 4cc719662a4..448d6b5ff8b 100644 --- a/lucene/suggest/src/test/org/apache/lucene/search/suggest/DocumentExpressionDictionaryTest.java +++ b/lucene/suggest/src/test/org/apache/lucene/search/suggest/DocumentExpressionDictionaryTest.java @@ -151,7 +151,7 @@ public class DocumentExpressionDictionaryTest extends LuceneTestCase { Random rand = random(); List termsToDel = new ArrayList<>(); for(Document doc : docs.values()) { - if(rand.nextBoolean()) { + if(rand.nextBoolean() && termsToDel.size() < docs.size()-1) { termsToDel.add(doc.get(FIELD_NAME)); } writer.addDocument(doc); @@ -174,6 +174,7 @@ public class DocumentExpressionDictionaryTest extends LuceneTestCase { } IndexReader ir = DirectoryReader.open(dir); + assertTrue("NumDocs should be > 0 but was " + ir.numDocs(), ir.numDocs() > 0); assertEquals(ir.numDocs(), docs.size()); Set sortFields = new HashSet(); sortFields.add(new SortField(WEIGHT_FIELD_NAME_1, SortField.Type.LONG));