beef up TestDuelingCodecs

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene5178@1515870 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2013-08-20 16:50:56 +00:00
parent 424369f491
commit d15e95bd05
2 changed files with 20 additions and 0 deletions

View File

@ -24,6 +24,7 @@ import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.codecs.Codec;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.NumericDocValuesField;
import org.apache.lucene.document.SortedSetDocValuesField;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.BytesRef;
@ -134,6 +135,11 @@ public class TestDuelingCodecs extends LuceneTestCase {
for (String trash : split) {
document.add(new SortedSetDocValuesField("sortedset", new BytesRef(trash)));
}
// add a numeric dv field sometimes
document.removeFields("sparsenumeric");
if (random.nextInt(4) == 2) {
document.add(new NumericDocValuesField("sparsenumeric", random.nextInt()));
}
writer.addDocument(document);
}

View File

@ -1972,6 +1972,20 @@ public abstract class LuceneTestCase extends Assert {
assertNull(info, rightValues);
}
}
{
Bits leftBits = MultiDocValues.getDocsWithField(leftReader, field);
Bits rightBits = MultiDocValues.getDocsWithField(rightReader, field);
if (leftBits != null && rightBits != null) {
assertEquals(info, leftBits.length(), rightBits.length());
for (int i = 0; i < leftBits.length(); i++) {
assertEquals(info, leftBits.get(i), rightBits.get(i));
}
} else {
assertNull(info, leftBits);
assertNull(info, rightBits);
}
}
}
}