#[warn(clippy::all, clippy::pedantic)]
#[allow(clippy::too_many_lines)]
pub mod lookup;
use std::collections::HashMap;
pub fn uniaxe(text: &str, table: &HashMap<char, char>) -> String {
let mut result = String::new();
for c in text.chars() {
if lookup::TEMPLATE.contains(c) {
result.push(c);
} else if let Some(&equiv) = table.get(&c) {
result.push(equiv);
} else if c.is_ascii() {
result.push(c);
}
}
result
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn conversion() {
let table = lookup::generate_table();
assert_eq!(
uniaxe("๐ฅ๐ข๐ฉ๐ฉ๐ฌ ๐ฑ๐ฅ๐ข๐ฏ๐ข ๐๐ซ๐๐ฌ๐ถ ๐๐ฅ๐ฆ๐ฐ ๐๐ฌ๐๐ฅโ๐ ๐ฟ๐๐๐ 123", &table),
"hello there EnJoy This GoThIc Text 123"
);
assert_eq!(
uniaxe("๐ฒ๐ณ๐ด๐ต๐ถ๏ฝ๏ฝ๏ฝ๏ฝ๏ฝ๏ฝ๏ฝ๏ฝ1234567890", &table),
"ijklmfghijklm1234567890"
);
assert_eq!(
uniaxe(
"โโฌโฌโฌโฌ๐๐ฎ๐๐ ๐ฟ๐ฒ๐บ๐ถ๐ป๐ฑ๐ฒ๐ฟ,โ๏ธ ๐ฌ๐ผ๐๐ฟ ๐๐ป๐๐ถ๐๐ถ๐ฟ๐๐ ๐ฒ๐
๐ฝ๐ถ๐ฟ๐ฒ๐ ๐ถ๐ป ๐ฎ๐ฐ๐ต๐ฟ๐ฏโโ---โฌโฌโฌโฌโฌโ #UdL04",
&table
),
"Last reminder, Your Antivirus expires in 24hr--- #UdL04"
);
}
#[test]
fn normal() {
let table = lookup::generate_table();
assert_eq!(
uniaxe(
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
&table
),
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
);
}
}