add fieldinfos check

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1291713 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2012-02-21 11:27:55 +00:00
parent 1f4a544b90
commit 546ec4b1be
1 changed files with 21 additions and 1 deletions

View File

@ -22,6 +22,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.Random;
import java.util.Set;
import java.util.TreeSet;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.MockAnalyzer;
@ -34,7 +35,6 @@ import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.FixedBitSet;
import org.apache.lucene.util.LineFileDocs;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.ReaderUtil;
import org.apache.lucene.util.automaton.AutomatonTestUtil;
import org.apache.lucene.util.automaton.CompiledAutomaton;
import org.apache.lucene.util.automaton.RegExp;
@ -140,6 +140,7 @@ public class TestDuelingCodecs extends LuceneTestCase {
assertTermVectors(leftReader, rightReader);
assertDocValues(leftReader, rightReader);
assertDeletedDocs(leftReader, rightReader);
assertFieldInfos(leftReader, rightReader);
}
/**
@ -614,6 +615,25 @@ public class TestDuelingCodecs extends LuceneTestCase {
}
}
public void assertFieldInfos(IndexReader leftReader, IndexReader rightReader) throws Exception {
FieldInfos leftInfos = MultiFields.getMergedFieldInfos(leftReader);
FieldInfos rightInfos = MultiFields.getMergedFieldInfos(rightReader);
// TODO: would be great to verify more than just the names of the fields!
TreeSet<String> left = new TreeSet<String>();
TreeSet<String> right = new TreeSet<String>();
for (FieldInfo fi : leftInfos) {
left.add(fi.name);
}
for (FieldInfo fi : rightInfos) {
right.add(fi.name);
}
assertEquals(info, left, right);
}
private static class RandomBits implements Bits {
FixedBitSet bits;