Skip to content

Commit

Permalink
Merge pull request #779 from hippietrail/split-attrs-vs-merged-attrs
Browse files Browse the repository at this point in the history
test: check that dictionary attributes can be spread over two entries
  • Loading branch information
elijah-potter authored Feb 27, 2025
2 parents c6783f1 + a3a9c9f commit 8a24ff9
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions harper-core/src/spell/hunspell/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,35 @@ mod tests {
assert!(is.unwrap().is_linking_verb());
}

#[test]
fn are_merged_attrs_same_as_spread_attrs() {
let merged_word = parse_word_list("1\nblork/DGS").unwrap();
let spread_word = parse_word_list("2\nblork/DG\nblork/S").unwrap();

let merged_attrs = parse_default_attribute_list();
let spread_attrs = parse_default_attribute_list();

let mut expanded1 = HashMap::new();
let mut expanded2 = HashMap::new();

merged_attrs.expand_marked_words(merged_word, &mut expanded1);
let expanded_merged: HashSet<String> = expanded1
.into_iter()
.map(|v| v.0.into_iter().collect())
.collect();

spread_attrs.expand_marked_words(spread_word, &mut expanded2);
let expanded_spread: HashSet<String> = expanded2
.into_iter()
.map(|v| v.0.into_iter().collect())
.collect();

assert_eq!(
expanded_merged.into_iter().collect::<HashSet<_>>(),
expanded_spread.into_iter().collect::<HashSet<_>>()
);
}

fn split(text: &str) -> CharString {
text.chars().collect()
}
Expand Down

0 comments on commit 8a24ff9

Please sign in to comment.