use anagram_generator::{ analyzer::PronounceabilityAnalyzer, scorer::{CharacterClassifier, ConsonantClusterRules, PronounceabilityScorer}, }; #[test] fn test_empty_string_scores_zero() { let analyzer = PronounceabilityAnalyzer::with_defaults(); assert_eq!(analyzer.score("").value(), 0); } #[test] fn test_good_pronounceable_words() { let analyzer = PronounceabilityAnalyzer::with_defaults(); assert!(analyzer.score("hello").value() > 60); assert!(analyzer.score("world").value() > 50); assert!(analyzer.score("create").value() > 60); } #[test] fn test_poor_pronounceable_words() { let analyzer = PronounceabilityAnalyzer::with_defaults(); assert!(analyzer.score("bcdfg").value() < 50); assert!(analyzer.score("xzqwk").value() < 50); } #[test] fn test_many_consecutive_consonants() { let analyzer = PronounceabilityAnalyzer::with_defaults(); assert!(analyzer.score("strngth").value() < 60); } #[test] fn test_character_classification() { let classifier = CharacterClassifier::default_french(); assert!(classifier.is_vowel('a')); assert!(classifier.is_vowel('e')); assert!(classifier.is_vowel('A')); assert!(!classifier.is_vowel('b')); assert!(classifier.is_consonant('b')); assert!(classifier.is_consonant('B')); } #[test] fn test_common_clusters() { let rules = ConsonantClusterRules::default_french(); assert!(rules.is_common_cluster("th")); assert!(rules.is_common_cluster("st")); assert!(rules.is_common_cluster("TH")); assert!(!rules.is_common_cluster("xz")); } #[test] fn test_alternating_patterns_get_bonus() { let analyzer = PronounceabilityAnalyzer::with_defaults(); // "banana" has good alternation (b-a-n-a-n-a) let score_good_alternation = analyzer.score("banana").value(); // "strength" has poor alternation let score_poor_alternation = analyzer.score("strength").value(); assert!(score_good_alternation > score_poor_alternation); } #[test] fn test_words_starting_with_consonants() { let analyzer = PronounceabilityAnalyzer::with_defaults(); let score_consonant = analyzer.score("banana").value(); let score_vowel = analyzer.score("ananas").value(); // Words starting with consonants should get a small bonus assert!(score_consonant >= score_vowel); } #[test] fn test_only_vowels_penalized() { let analyzer = PronounceabilityAnalyzer::with_defaults(); assert!(analyzer.score("aeiou").value() < 80); } #[test] fn test_no_vowels_heavily_penalized() { let analyzer = PronounceabilityAnalyzer::with_defaults(); assert!(analyzer.score("bcdfg").value() < 50); } #[test] fn test_common_consonant_clusters_not_penalized() { let analyzer = PronounceabilityAnalyzer::with_defaults(); // "three" has "th" which is a common cluster let score_with_common = analyzer.score("three").value(); // Should have a decent score despite consecutive consonants assert!(score_with_common > 60); }