public void testAllDocs() throws Exception {
int maxDoc = 3;
Directory dir = newDirectory();
IndexReader reader = createReaderWithNDocs(random(), maxDoc, dir);
try {
ScoredDocIDs all = ScoredDocIdsUtils.createAllDocsScoredDocIDs(reader);
assertEquals("invalid size", maxDoc, all.size());
ScoredDocIDsIterator iter = all.iterator();
int doc = 0;
while (iter.next()) {
assertEquals("invalid doc ID: " + iter.getDocID(), doc++, iter.getDocID());
assertEquals("invalid score: " + iter.getScore(), ScoredDocIDsIterator.DEFAULT_SCORE, iter.getScore(), 0.0f);
}
assertEquals("invalid maxDoc: " + doc, maxDoc, doc);
DocIdSet docIDs = all.getDocIDs();
assertTrue("should be cacheable", docIDs.isCacheable());
DocIdSetIterator docIDsIter = docIDs.iterator();
assertEquals("nextDoc() hasn't been called yet", -1, docIDsIter.docID());
assertEquals(0, docIDsIter.nextDoc());
assertEquals(1, docIDsIter.advance(1));