unic_char_basics/
noncharacter.rspub fn is_noncharacter(codepoint: char) -> bool {
match codepoint {
'\u{fdd0}'..='\u{fdef}'
| '\u{fffe}'..='\u{ffff}'
| '\u{1_fffe}'..='\u{1_ffff}'
| '\u{2_fffe}'..='\u{2_ffff}'
| '\u{3_fffe}'..='\u{3_ffff}'
| '\u{4_fffe}'..='\u{4_ffff}'
| '\u{5_fffe}'..='\u{5_ffff}'
| '\u{6_fffe}'..='\u{6_ffff}'
| '\u{7_fffe}'..='\u{7_ffff}'
| '\u{8_fffe}'..='\u{8_ffff}'
| '\u{9_fffe}'..='\u{9_ffff}'
| '\u{A_fffe}'..='\u{A_ffff}'
| '\u{B_fffe}'..='\u{B_ffff}'
| '\u{C_fffe}'..='\u{C_ffff}'
| '\u{D_fffe}'..='\u{D_ffff}'
| '\u{E_fffe}'..='\u{E_ffff}'
| '\u{F_fffe}'..='\u{F_ffff}'
| '\u{10_fffe}'..='\u{10_ffff}' => true,
_ => false,
}
}
#[cfg(test)]
mod tests {
use super::is_noncharacter;
#[test]
fn test_sample_codepoints() {
assert_eq!(is_noncharacter('\u{0}'), false);
assert_eq!(is_noncharacter('\u{20}'), false);
assert_eq!(is_noncharacter('\u{41}'), false);
assert_eq!(is_noncharacter('\u{80}'), false);
assert_eq!(is_noncharacter('\u{200c}'), false);
assert_eq!(is_noncharacter('\u{d7ff}'), false);
assert_eq!(is_noncharacter('\u{e000}'), false);
assert_eq!(is_noncharacter('\u{e001}'), false);
assert_eq!(is_noncharacter('\u{f8fe}'), false);
assert_eq!(is_noncharacter('\u{f8ff}'), false);
assert_eq!(is_noncharacter('\u{f900}'), false);
assert_eq!(is_noncharacter('\u{fdcf}'), false);
assert_eq!(is_noncharacter('\u{fdd0}'), true);
assert_eq!(is_noncharacter('\u{fdd1}'), true);
assert_eq!(is_noncharacter('\u{fdee}'), true);
assert_eq!(is_noncharacter('\u{fdef}'), true);
assert_eq!(is_noncharacter('\u{fdf0}'), false);
assert_eq!(is_noncharacter('\u{fff0}'), false);
assert_eq!(is_noncharacter('\u{fffc}'), false);
assert_eq!(is_noncharacter('\u{fffd}'), false);
assert_eq!(is_noncharacter('\u{fffe}'), true);
assert_eq!(is_noncharacter('\u{ffff}'), true);
assert_eq!(is_noncharacter('\u{1_0000}'), false);
assert_eq!(is_noncharacter('\u{1_0001}'), false);
assert_eq!(is_noncharacter('\u{1_fffd}'), false);
assert_eq!(is_noncharacter('\u{1_fffe}'), true);
assert_eq!(is_noncharacter('\u{1_ffff}'), true);
assert_eq!(is_noncharacter('\u{e_0000}'), false);
assert_eq!(is_noncharacter('\u{e_0001}'), false);
assert_eq!(is_noncharacter('\u{e_fffd}'), false);
assert_eq!(is_noncharacter('\u{e_fffe}'), true);
assert_eq!(is_noncharacter('\u{e_ffff}'), true);
assert_eq!(is_noncharacter('\u{f_0000}'), false);
assert_eq!(is_noncharacter('\u{f_0001}'), false);
assert_eq!(is_noncharacter('\u{f_fffd}'), false);
assert_eq!(is_noncharacter('\u{f_fffe}'), true);
assert_eq!(is_noncharacter('\u{f_ffff}'), true);
assert_eq!(is_noncharacter('\u{10_0000}'), false);
assert_eq!(is_noncharacter('\u{10_0001}'), false);
assert_eq!(is_noncharacter('\u{10_fffd}'), false);
assert_eq!(is_noncharacter('\u{10_fffe}'), true);
assert_eq!(is_noncharacter('\u{10_ffff}'), true);
}
}