use super::data::{SOURCE_CODEPOINTS, TARGET_STRINGS};
#[inline]
pub fn lookup(c: char) -> Option<&'static str> {
SOURCE_CODEPOINTS
.binary_search(&c)
.ok()
.map(|i| TARGET_STRINGS[i])
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_known_confusable_mapping() {
assert_eq!(lookup('\u{0430}'), Some("a"));
}
#[test]
fn test_ascii_char_in_table() {
assert_eq!(lookup('m'), Some("rn"));
}
#[test]
fn test_non_confusable_non_ascii() {
assert_eq!(lookup('\u{2603}'), None);
}
#[test]
fn test_quote_mapping() {
assert_eq!(lookup('"'), Some("''"));
}
#[test]
fn test_m_to_rn_in_table() {
let result = lookup('m');
assert_eq!(result, Some("rn"));
}
}