mirror of https://github.com/apache/lucene.git
add two more tests
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene4547@1439161 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
20159c0dcd
commit
bf36270469
|
@ -813,8 +813,6 @@ public class TestDemoDocValue extends LuceneTestCase {
|
|||
directory.close();
|
||||
}
|
||||
|
||||
// nocommit: test exactly 32766, also add field-level check so you get exc faster
|
||||
// same for sorted bytes
|
||||
public void testTooLargeBytes() throws IOException {
|
||||
Analyzer analyzer = new MockAnalyzer(random());
|
||||
|
||||
|
@ -861,4 +859,59 @@ public class TestDemoDocValue extends LuceneTestCase {
|
|||
iwriter.close();
|
||||
directory.close();
|
||||
}
|
||||
|
||||
public void testVeryLargeButLegalBytes() throws IOException {
|
||||
Analyzer analyzer = new MockAnalyzer(random());
|
||||
|
||||
Directory directory = newDirectory();
|
||||
// we don't use RandomIndexWriter because it might add more docvalues than we expect !!!!1
|
||||
IndexWriterConfig iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
|
||||
iwc.setMergePolicy(newLogMergePolicy());
|
||||
IndexWriter iwriter = new IndexWriter(directory, iwc);
|
||||
Document doc = new Document();
|
||||
byte bytes[] = new byte[32766];
|
||||
BytesRef b = new BytesRef(bytes);
|
||||
random().nextBytes(bytes);
|
||||
doc.add(new BinaryDocValuesField("dv", b));
|
||||
iwriter.addDocument(doc);
|
||||
iwriter.close();
|
||||
|
||||
// Now search the index:
|
||||
IndexReader ireader = DirectoryReader.open(directory); // read-only=true
|
||||
assert ireader.leaves().size() == 1;
|
||||
BinaryDocValues dv = ireader.leaves().get(0).reader().getBinaryDocValues("dv");
|
||||
BytesRef scratch = new BytesRef();
|
||||
dv.get(0, scratch);
|
||||
assertEquals(new BytesRef(bytes), scratch);
|
||||
|
||||
ireader.close();
|
||||
directory.close();
|
||||
}
|
||||
|
||||
public void testVeryLargeButLegalSortedBytes() throws IOException {
|
||||
Analyzer analyzer = new MockAnalyzer(random());
|
||||
|
||||
Directory directory = newDirectory();
|
||||
// we don't use RandomIndexWriter because it might add more docvalues than we expect !!!!1
|
||||
IndexWriterConfig iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
|
||||
iwc.setMergePolicy(newLogMergePolicy());
|
||||
IndexWriter iwriter = new IndexWriter(directory, iwc);
|
||||
Document doc = new Document();
|
||||
byte bytes[] = new byte[32766];
|
||||
BytesRef b = new BytesRef(bytes);
|
||||
random().nextBytes(bytes);
|
||||
doc.add(new SortedDocValuesField("dv", b));
|
||||
iwriter.addDocument(doc);
|
||||
iwriter.close();
|
||||
|
||||
// Now search the index:
|
||||
IndexReader ireader = DirectoryReader.open(directory); // read-only=true
|
||||
assert ireader.leaves().size() == 1;
|
||||
BinaryDocValues dv = ireader.leaves().get(0).reader().getSortedDocValues("dv");
|
||||
BytesRef scratch = new BytesRef();
|
||||
dv.get(0, scratch);
|
||||
assertEquals(new BytesRef(bytes), scratch);
|
||||
ireader.close();
|
||||
directory.close();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue