Added unit test

This commit is contained in:
Paul Masurel
2018-02-21 00:13:04 +09:00
parent 2c3e33895a
commit 6fb114224a

View File

@@ -51,7 +51,8 @@ impl DocSet for EmptyScorer {
}
fn doc(&self) -> DocId {
DocId::max_value()
panic!("You may not call .doc() on a scorer \
where the last call to advance() did not return true.");
}
fn size_hint(&self) -> u32 {
@@ -122,3 +123,21 @@ impl<TDocSet: DocSet + 'static> Scorer for ConstScorer<TDocSet> {
1f32
}
}
#[cfg(test)]
mod tests {
use super::EmptyScorer;
use DocSet;
#[test]
fn test_empty_scorer() {
let mut empty_scorer = EmptyScorer;
assert!(!empty_scorer.advance());
}
#[test]
#[should_panic]
fn test_empty_scorer_panic_on_doc_call() {
EmptyScorer.doc();
}
}