diff --git a/src/test_cases.rs b/src/test_cases.rs index 3cd008e..a915766 100644 --- a/src/test_cases.rs +++ b/src/test_cases.rs @@ -1,15 +1,19 @@ use crate::Segmenter; /// Run a segmenter against the built-in test cases -pub fn run(segmenter: Segmenter) { +pub fn run(segmenter: &Segmenter) { for test in TEST_CASES.iter().copied() { - let mut out = Vec::new(); - segmenter.segment(&test.join(""), &mut out); - let cmp = out.iter().map(|s| &*s).collect::>(); - assert_eq!(cmp, test); + assert_segments(segmenter, test); } } +pub fn assert_segments(segmenter: &Segmenter, s: &[&str]) { + let mut out = Vec::new(); + segmenter.segment(&s.join(""), &mut out); + let cmp = out.iter().map(|s| &*s).collect::>(); + assert_eq!(cmp, s); +} + /// Built-in test cases /// /// These are exposed so that you can test with different data sources. diff --git a/src/test_data.rs b/src/test_data.rs index 63a4954..bd86c1d 100644 --- a/src/test_data.rs +++ b/src/test_data.rs @@ -9,7 +9,7 @@ use super::Segmenter; #[test] fn test_data() { - crate::test_cases::run(segmenter()); + crate::test_cases::run(&segmenter()); } pub fn segmenter() -> Segmenter {