1#![warn(clippy::pedantic)]
2
3pub mod detector;
4pub mod score;
5pub mod unicode_map;
6
7pub use detector::detect_confusables;
8pub use score::confusable_score;
9
10#[cfg(test)]
11mod tests {
12 use super::*;
13
14 #[test]
15 fn test_detect_cyrillic_homoglyph() {
16 let input = "раypal";
17 let flags = detect_confusables(input);
18 assert!(flags.contains(&"VISUAL_MISMATCH_DETECTED".to_string()));
19 assert!(flags.contains(&"CROSS_SCRIPT_MIXING".to_string()));
20 }
21
22 #[test]
23 fn test_detect_f_hook() {
24 let input = "ƒunction";
25 let flags = detect_confusables(input);
26 assert!(flags.contains(&"VISUAL_MISMATCH_DETECTED".to_string()));
27 }
28
29 #[test]
30 fn test_clean_input_no_flags() {
31 let input = "hello";
32 let flags = detect_confusables(input);
33 assert!(flags.is_empty());
34 }
35
36 #[test]
37 fn test_confusable_score_non_latin() {
38 let input = "раypal";
39 let score = confusable_score(input);
40 assert!(score > 0.0);
41 assert!(score <= 1.0);
42 }
43
44 #[test]
45 fn test_confusable_score_clean() {
46 let input = "hello world";
47 let score = confusable_score(input);
48 assert_eq!(score, 0.0);
49 }
50
51 #[test]
52 fn test_impersonation_detection() {
53 let input = "раypal";
54 let flags = detect_confusables(input);
55 assert!(flags.contains(&"POTENTIAL_IMPERSONATION".to_string()));
56 }
57}