mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-01-08 01:52:54 +00:00
Added unit test
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user