Added unit test

This commit is contained in:
Paul Masurel
2018-02-20 13:12:05 +09:00
parent de6a3987a9
commit 3fd6d7125b
2 changed files with 21 additions and 1 deletions

View File

@@ -359,7 +359,11 @@ impl IndexWriter {
.add_segment(self.generation, segment_entry);
}
#[doc(hidden)]
/// *Experimental & Advanced API* Creates a new segment.
/// and marks it as currently in write.
///
/// This method is useful only for users trying to do complex
/// operations, like converting an index format to another.
pub fn new_segment(&self) -> Segment {
self.segment_updater.new_segment()
}

View File

@@ -69,4 +69,20 @@ pub mod tests {
assert_eq!(postings.skip_next(6000u32), SkipResult::End);
}
#[test]
pub fn test_fill_buffer() {
let doc_ids: Vec<DocId> = (1u32..210u32).collect();
let mut postings = VecDocSet::from(doc_ids);
let mut buffer = vec![1000u32; 100];
assert_eq!(postings.fill_buffer(&mut buffer[..]), 100);
for i in 0u32..100u32 {
assert_eq!(buffer[i as usize], i + 1);
}
assert_eq!(postings.fill_buffer(&mut buffer[..]), 100);
for i in 0u32..100u32 {
assert_eq!(buffer[i as usize], i + 101);
}
assert_eq!(postings.fill_buffer(&mut buffer[..]), 9);
}
}