pub mod entities;
pub mod html_blocks;
pub mod html_re;
pub mod ucmicro;
pub mod utils;
#[cfg(test)]
mod tests {
use super::{entities, ucmicro};
#[test]
fn entity_table_is_sorted_and_looks_up_like_entities() {
assert_eq!(entities::ENTITIES.len(), 2125);
assert!(entities::ENTITIES.windows(2).all(|w| w[0].0 < w[1].0));
for (name, want) in [
("amp", Some("&")),
("AMP", Some("&")),
("Amp", None),
("ngE", Some("\u{2267}\u{338}")),
("NotNestedGreaterGreater", Some("\u{2AA2}\u{338}")),
("fjlig", Some("fj")),
("ThickSpace", Some("\u{205F}\u{200A}")),
("NewLine", Some("\n")),
("Tab", Some("\t")),
("bne", Some("=\u{20E5}")),
("nbsp", Some("\u{A0}")),
("zwnj", Some("\u{200C}")),
("nosuch", None),
("", None),
("amp;", None),
] {
assert_eq!(entities::lookup(name), want, "{name}");
}
}
#[test]
fn unicode_tables_are_ordered_ranges_without_surrogates() {
for table in [&ucmicro::P[..], &ucmicro::S[..]] {
assert!(table.iter().all(|&(lo, hi)| lo <= hi));
assert!(
table.windows(2).all(|w| w[0].1 + 1 < w[1].0),
"sorted, disjoint, merged"
);
assert!(!table.iter().any(|&(lo, hi)| lo <= 0xDFFF && hi >= 0xD800));
}
for (c, p, s) in [
(0x21, true, false),
(0x24, false, true),
(0x41, false, false),
(0xA7, true, false),
(0x20AC, false, true),
(0x1F600, false, true),
(0x3000, false, false),
(0x5F, true, false),
(0x2E, true, false),
(0x7E, false, true),
(0x10FFFF, false, false),
(0xFF04, false, true),
] {
assert_eq!((ucmicro::is_p(c), ucmicro::is_s(c)), (p, s), "{c:#x}");
}
}
}