1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
pub mod unicode;
pub mod collections;
#[cfg(test)]
mod tests {
use super::unicode::CodePoint;
use super::unicode::Ucd;
use super::unicode::Normalization;
use super::unicode::props::*;
#[test]
fn code_point_to_string() {
let cp_string = CodePoint::new(0xAC00).unwrap().to_string();
assert_eq!("U+AC00", cp_string);
}
#[test]
fn code_point_gc() {
let cp = CodePoint::new(0xAC00).unwrap();
match cp.gc() {
Gc::Lo => (),
_ => panic!("Not Lo"),
}
}
#[test]
fn code_point_na() {
let c = '🦀';
if c.na() != "CRAB" {
panic!("Not \"CRAB\"");
}
}
#[test]
fn str_nfd() {
let s = "각";
assert_eq!(s.to_nfd(), "\u{1100}\u{1161}\u{11A8}");
}
#[test]
fn test_starter() {
let cp1 = 0x00A0;
assert_eq!(crate::unicode::normalization::starter(cp1), true);
let cp2 = 0x0344;
assert_eq!(crate::unicode::normalization::starter(cp2), false);
}
#[test]
fn test_singleton() {
let cp = 0x00A0;
assert_eq!(crate::unicode::normalization::singleton_decomposition(cp), false);
let cp2 = 0x0300;
assert_eq!(crate::unicode::normalization::singleton_decomposition(cp2), false);
let cp3 = 0x2126;
assert_eq!(crate::unicode::normalization::singleton_decomposition(cp3), true);
}
#[test]
fn test_non_starter_decomposition() {
let cp1 = 0x0344;
assert_eq!(crate::unicode::normalization::non_starter_decomposition(cp1), true);
let cp2 = 0x0F73;
assert_eq!(crate::unicode::normalization::non_starter_decomposition(cp2), true);
}
}