Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
style(fst-dict): move relevant tests from full_dictionary.rs to mod.rs
Grant Lemons180ea3034423
diff --git a/harper-core/src/spell/full_dictionary.rs b/harper-core/src/spell/full_dictionary.rsindex d2c56d100..38ae04169 100644--- a/harper-core/src/spell/full_dictionary.rs+++ b/harper-core/src/spell/full_dictionary.rs@@ -249,35 +249,8 @@ impl Dictionary for FullDictionary {mod tests {use itertools::Itertools;- use super::super::{edit_distance, seq_to_normalized};use crate::{Dictionary, FullDictionary};- fn assert_edit_dist(source: &str, target: &str, expected: u8) {- let source: Vec<_> = source.chars().collect();- let target: Vec<_> = target.chars().collect();-- let dist = edit_distance(&source, &target);- assert_eq!(dist, expected)- }-- #[test]- fn normalizes_weve() {- let word = vec!['w', 'e', '’', 'v', 'e'];- let norm = seq_to_normalized(&word);-- assert_eq!(norm.clone(), vec!['w', 'e', '\'', 'v', 'e'])- }-- #[test]- fn simple1() {- assert_edit_dist("kitten", "sitting", 3)- }-- #[test]- fn simple2() {- assert_edit_dist("saturday", "sunday", 3)- }-#[test]fn curated_contains_no_duplicates() {let dict = FullDictionary::curated();diff --git a/harper-core/src/spell/mod.rs b/harper-core/src/spell/mod.rsindex de20fd2e4..bd0fcd3e6 100644--- a/harper-core/src/spell/mod.rs+++ b/harper-core/src/spell/mod.rs@@ -95,6 +95,8 @@ fn seq_to_normalized(seq: &[char]) -> Cow<'_, [char]> {fn char_to_normalized(c: char) -> char {match c {'’' => '\'',+ '‘' => '\'',+ ''' => '\'',_ => c,}}@@ -147,12 +149,37 @@ fn edit_distance(source: &[char], target: &[char]) -> u8 {mod tests {use itertools::Itertools;- use crate::spell::edit_distance;-use super::{- order_suggestions, suggest_correct_spelling_str, Dictionary, FstDictionary, FullDictionary,+ edit_distance, order_suggestions, seq_to_normalized, suggest_correct_spelling_str,+ Dictionary, FstDictionary, FullDictionary,};+ fn assert_edit_dist(source: &str, target: &str, expected: u8) {+ let source: Vec<_> = source.chars().collect();+ let target: Vec<_> = target.chars().collect();++ let dist = edit_distance(&source, &target);+ assert_eq!(dist, expected)+ }++ #[test]+ fn normalizes_weve() {+ let word = vec!['w', 'e', '’', 'v', 'e'];+ let norm = seq_to_normalized(&word);++ assert_eq!(norm.clone(), vec!['w', 'e', '\'', 'v', 'e'])+ }++ #[test]+ fn simple_edit_distance_1() {+ assert_edit_dist("kitten", "sitting", 3)+ }++ #[test]+ fn simple_edit_distance_2() {+ assert_edit_dist("saturday", "sunday", 3)+ }+#[test]fn produces_no_duplicates() {let results = suggest_correct_spelling_str("punctation", 100, 3, &FstDictionary::curated());