| 1 |
extern crate unicode_xid; |
| 2 |
use unicode_xid::UnicodeXID; |
| 3 |
/// A `char` in Rust is a Unicode Scalar Value |
| 4 |
/// |
| 5 |
/// See: http://www.unicode.org/glossary/#unicode_scalar_value |
| 6 |
fn all_valid_chars() -> impl Iterator<Item = char> { |
| 7 |
(0u32..=0xD7FF).chain(0xE000u32..=0x10FFFF).map(|u| { |
| 8 |
core::convert::TryFrom::try_from(u) |
| 9 |
.expect("The selected range should be infallible if the docs match impl") |
| 10 |
}) |
| 11 |
} |
| 12 |
|
| 13 |
#[test] |
| 14 |
fn all_valid_chars_do_not_panic_for_is_xid_start() { |
| 15 |
for c in all_valid_chars() { |
| 16 |
let _ = UnicodeXID::is_xid_start(c); |
| 17 |
} |
| 18 |
} |
| 19 |
|
| 20 |
#[test] |
| 21 |
fn all_valid_chars_do_not_panic_for_is_xid_continue() { |
| 22 |
for c in all_valid_chars() { |
| 23 |
let _ = UnicodeXID::is_xid_continue(c); |
| 24 |
} |
| 25 |
} |