1 #![feature(test)]
2 #![feature(non_ascii_idents)]
3 
4 #[cfg(test)]
5 extern crate test;
6 extern crate wana_kana;
7 
8 #[cfg(test)]
9 extern crate speculate;
10 
11 #[cfg(test)]
12 use speculate::speculate;
13 
14 #[cfg(feature = "enable_regex")]
15 use regex::Regex;
16 use wana_kana::is_romaji::*;
17 
18 speculate! {
19     it "sane defaults" {
20         assert_eq!(is_romaji(""), false);
21 
22         #[cfg(feature = "enable_regex")]
23         assert_eq!(is_romaji_with_whitelist("", None), false);
24     }
25     it "A is romaji" { assert_eq!(is_romaji("A"), true); }
26     it "xYz is romaji" { assert_eq!(is_romaji("xYz"), true); }
27     it "Tōkyō and Ōsaka is romaji" { assert_eq!(is_romaji("Tōkyō and Ōsaka"), true); }
28     it "あアA is not romaji" { assert_eq!(is_romaji("あアA"), false); }
29     it "お願い is not romaji" { assert_eq!(is_romaji("お願い"), false); }
30     it "熟成 is not romaji" { assert_eq!(is_romaji("熟成"), false); }
31     it "passes latin punctuation" { assert_eq!(is_romaji("a*b&c-d"), true); }
32     it "passes latin numbers" { assert_eq!(is_romaji("0123456789"), true); }
33     it "fails zenkaku punctuation" { assert_eq!(is_romaji("a!b&cーd"), false); }
34     it "fails zenkaku latin" { assert_eq!(is_romaji("hello"), false); }
35 
36     #[cfg(feature = "enable_regex")]
37     it "accepts optional allowed chars" { assert_eq!(is_romaji_with_whitelist("a!b&cーd", Some(&Regex::new(r"[!ー]").unwrap())), true); }
38 }
39