Add check_segments function

This commit is contained in:
Dirkjan Ochtman 2021-02-04 11:20:36 +01:00
parent f3aaaa656d
commit 8c08bb9e14
1 changed files with 6 additions and 0 deletions

View File

@ -15,6 +15,12 @@ pub fn assert_segments(segmenter: &Segmenter, s: &[&str]) {
assert_eq!(cmp, s); assert_eq!(cmp, s);
} }
pub fn check_segments(segmenter: &Segmenter, s: &[&str]) -> bool {
let mut out = Vec::new();
segmenter.segment(&s.join(""), &mut out);
s == out.iter().map(|s| &*s).collect::<Vec<_>>()
}
/// Built-in test cases /// Built-in test cases
/// ///
/// These are exposed so that you can test with different data sources. /// These are exposed so that you can test with different data sources.