use unic_char_property::TotalCharProperty;
char_property! {
pub enum GraphemeClusterBreak {
abbr => "GCB";
long => "Grapheme_Cluster_Break";
human => "Grapheme Cluster Break";
CR {
abbr => CR,
long => CR,
human => "Carriage Return",
}
LF {
abbr => LF,
long => LF,
human => "Line Feed",
}
Control {
abbr => CN,
long => Control,
human => "Control",
}
Extend {
abbr => EX,
long => Extend,
human => "Extend",
}
ZWJ {
abbr => ZWJ,
long => ZWJ,
human => "Zero Width Joiner (ZWJ)",
}
RegionalIndicator {
abbr => RI,
long => Regional_Indicator,
human => "Regional Indicator",
}
Prepend {
abbr => PP,
long => Prepend,
human => "Prepend",
}
SpacingMark {
abbr => SM,
long => SpacingMark,
human => "Spacing Mark",
}
L {
abbr => L,
long => L,
human => "Hangul Syllable Type L",
}
V {
abbr => V,
long => V,
human => "Hangul Syllable Type V",
}
T {
abbr => T,
long => T,
human => "Hangul Syllable Type T",
}
LV {
abbr => LV,
long => LV,
human => "Hangul Syllable Type LV",
}
LVT {
abbr => LVT,
long => LVT,
human => "Hangul Syllable Type LVT",
}
EBase {
abbr => EB,
long => E_Base,
human => "Emoji Base",
}
EModifier {
abbr => EM,
long => E_Modifier,
human => "Emoji Modifier",
}
GlueAfterZwj {
abbr => GAZ,
long => Glue_After_Zwj,
human => "Glue After ZWJ",
}
EBaseGAZ {
abbr => EBG,
long => E_Base_GAZ,
human => "Emoji Base and Glue After ZWJ",
}
Other {
abbr => XX,
long => Other,
human => "Other",
}
}
pub mod abbr_names for abbr;
pub mod long_names for long;
}
impl TotalCharProperty for GraphemeClusterBreak {
fn of(ch: char) -> Self {
Self::of(ch)
}
}
impl Default for GraphemeClusterBreak {
fn default() -> Self {
GraphemeClusterBreak::Other
}
}
mod data {
use super::long_names as GCB;
use unic_char_property::tables::CharDataTable;
pub const GRAPHEME_CLUSTER_BREAK_TABLE: CharDataTable<super::GraphemeClusterBreak> =
include!("../tables/grapheme_cluster_break.rsv");
}
impl GraphemeClusterBreak {
pub fn of(ch: char) -> GraphemeClusterBreak {
data::GRAPHEME_CLUSTER_BREAK_TABLE.find_or_default(ch)
}
}
#[cfg(test)]
mod tests {
use super::GraphemeClusterBreak as GCB;
use unic_char_property::EnumeratedCharProperty;
#[test]
fn test_ascii() {
assert_eq!(GCB::of('\u{0000}'), GCB::Control);
assert_eq!(GCB::of('\u{0040}'), GCB::Other);
assert_eq!(GCB::of('\u{0041}'), GCB::Other);
assert_eq!(GCB::of('\u{0062}'), GCB::Other);
assert_eq!(GCB::of('\u{007F}'), GCB::Control);
}
#[test]
fn test_bmp() {
assert_eq!(GCB::of('\u{0590}'), GCB::Other);
assert_eq!(GCB::of('\u{05D0}'), GCB::Other);
assert_eq!(GCB::of('\u{05D1}'), GCB::Other);
assert_eq!(GCB::of('\u{05FF}'), GCB::Other);
assert_eq!(GCB::of('\u{0600}'), GCB::Prepend);
assert_eq!(GCB::of('\u{0627}'), GCB::Other);
assert_eq!(GCB::of('\u{07BF}'), GCB::Other);
assert_eq!(GCB::of('\u{07C0}'), GCB::Other);
assert_eq!(GCB::of('\u{085F}'), GCB::Other);
assert_eq!(GCB::of('\u{0860}'), GCB::Other);
assert_eq!(GCB::of('\u{0870}'), GCB::Other);
assert_eq!(GCB::of('\u{089F}'), GCB::Other);
assert_eq!(GCB::of('\u{08A0}'), GCB::Other);
assert_eq!(GCB::of('\u{089F}'), GCB::Other);
assert_eq!(GCB::of('\u{08FF}'), GCB::Extend);
assert_eq!(GCB::of('\u{20A0}'), GCB::Other);
assert_eq!(GCB::of('\u{20CF}'), GCB::Other);
assert_eq!(GCB::of('\u{FB1D}'), GCB::Other);
assert_eq!(GCB::of('\u{FB4F}'), GCB::Other);
assert_eq!(GCB::of('\u{FB50}'), GCB::Other);
assert_eq!(GCB::of('\u{FDCF}'), GCB::Other);
assert_eq!(GCB::of('\u{FDF0}'), GCB::Other);
assert_eq!(GCB::of('\u{FDFF}'), GCB::Other);
assert_eq!(GCB::of('\u{FE70}'), GCB::Other);
assert_eq!(GCB::of('\u{FEFE}'), GCB::Other);
assert_eq!(GCB::of('\u{FEFF}'), GCB::Control);
assert_eq!(GCB::of('\u{FDD0}'), GCB::Other);
assert_eq!(GCB::of('\u{FDD1}'), GCB::Other);
assert_eq!(GCB::of('\u{FDEE}'), GCB::Other);
assert_eq!(GCB::of('\u{FDEF}'), GCB::Other);
assert_eq!(GCB::of('\u{FFFE}'), GCB::Other);
assert_eq!(GCB::of('\u{FFFF}'), GCB::Other);
}
#[test]
fn test_smp() {
assert_eq!(GCB::of('\u{10800}'), GCB::Other);
assert_eq!(GCB::of('\u{10FFF}'), GCB::Other);
assert_eq!(GCB::of('\u{1E800}'), GCB::Other);
assert_eq!(GCB::of('\u{1EDFF}'), GCB::Other);
assert_eq!(GCB::of('\u{1EE00}'), GCB::Other);
assert_eq!(GCB::of('\u{1EEFF}'), GCB::Other);
assert_eq!(GCB::of('\u{1EF00}'), GCB::Other);
assert_eq!(GCB::of('\u{1EFFF}'), GCB::Other);
}
#[test]
fn test_unassigned_planes() {
assert_eq!(GCB::of('\u{30000}'), GCB::Other);
assert_eq!(GCB::of('\u{40000}'), GCB::Other);
assert_eq!(GCB::of('\u{50000}'), GCB::Other);
assert_eq!(GCB::of('\u{60000}'), GCB::Other);
assert_eq!(GCB::of('\u{70000}'), GCB::Other);
assert_eq!(GCB::of('\u{80000}'), GCB::Other);
assert_eq!(GCB::of('\u{90000}'), GCB::Other);
assert_eq!(GCB::of('\u{a0000}'), GCB::Other);
}
#[test]
fn test_abbr_name() {
assert_eq!(GCB::CR.abbr_name(), "CR");
}
#[test]
fn test_long_name() {
assert_eq!(GCB::CR.long_name(), "CR");
}
#[test]
fn test_human_name() {
assert_eq!(GCB::CR.human_name(), "Carriage Return");
}
}