test_word()

This commit is contained in:
Lewis Wynne 2025-03-11 13:55:17 +00:00
parent 04718f77b2
commit 4da4f86119
2 changed files with 386 additions and 369 deletions

File diff suppressed because it is too large Load diff

View file

@ -10,21 +10,30 @@ fn test_joinstem() {
assert_eq!(
joinstem(
Some(-2),
Some(vec!["ephemeris".to_string(), "iris".to_string(), ".*itis".to_string()])
Some(vec![
"ephemeris".to_string(),
"iris".to_string(),
".*itis".to_string()
])
),
"(?:ephemer|ir|.*it)"
);
assert_eq!(joinstem(None, Some(vec!["ephemeris".to_string()])), "(?:ephemeris)");
assert_eq!(
joinstem(None, Some(vec!["ephemeris".to_string()])),
"(?:ephemeris)"
);
assert_eq!(joinstem(Some(5), None), "(?:)");
assert_eq!(joinstem(None, None), "(?:)");
}
#[test]
fn test_bysize() {
let words = vec!["ant", "cat", "dog", "pig", "frog", "goat", "horse", "elephant"]
.iter()
.map(|s| s.to_string())
.collect();
let words = vec![
"ant", "cat", "dog", "pig", "frog", "goat", "horse", "elephant",
]
.iter()
.map(|s| s.to_string())
.collect();
let result = bysize(words);
if let Some(set) = result.get(&3) {
let mut sorted_words: Vec<&String> = set.iter().collect();
@ -77,9 +86,6 @@ fn test_words() {
fn test_word() {
let word = Word::new(String::from("fox"));
assert_eq!(word.unwrap().get(), "fox");
let word = Word::new(String::from(""));
word.unwrap();
}
#[test]