Skip to content

Commit

Permalink
Added unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
fulmicoton committed Feb 20, 2018
1 parent de6a398 commit 3fd6d71
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/indexer/index_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
16 changes: 16 additions & 0 deletions src/query/vec_docset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}

0 comments on commit 3fd6d71

Please sign in to comment.