char: add is_lowercase(), is_uppercase()
This commit is contained in:
parent
47271ab4c8
commit
eb0cdc02e3
@ -41,6 +41,26 @@ import is_alphabetic = unicode::derived_property::Alphabetic;
|
||||
import is_XID_start = unicode::derived_property::XID_Start;
|
||||
import is_XID_continue = unicode::derived_property::XID_Continue;
|
||||
|
||||
/*
|
||||
Function: is_lowercase
|
||||
|
||||
Indicates whether a character is in lower case, defined in terms of the
|
||||
Unicode General Category 'Ll'.
|
||||
*/
|
||||
pure fn is_lowercase(c: char) -> bool {
|
||||
ret unicode::general_category::Ll(c);
|
||||
}
|
||||
|
||||
/*
|
||||
Function: is_uppercase
|
||||
|
||||
Indicates whether a character is in upper case, defined in terms of the
|
||||
Unicode General Category 'Lu'.
|
||||
*/
|
||||
pure fn is_uppercase(c: char) -> bool {
|
||||
ret unicode::general_category::Lu(c);
|
||||
}
|
||||
|
||||
/*
|
||||
Function: is_whitespace
|
||||
|
||||
|
@ -3,6 +3,24 @@ import core::*;
|
||||
use std;
|
||||
import char;
|
||||
|
||||
#[test]
|
||||
fn test_is_lowercase() {
|
||||
assert char::is_lowercase('a');
|
||||
assert char::is_lowercase('ö');
|
||||
assert char::is_lowercase('ß');
|
||||
assert !char::is_lowercase('Ü');
|
||||
assert !char::is_lowercase('P');
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_is_uppercase() {
|
||||
assert !char::is_uppercase('h');
|
||||
assert !char::is_uppercase('ä');
|
||||
assert !char::is_uppercase('ß');
|
||||
assert char::is_uppercase('Ö');
|
||||
assert char::is_uppercase('T');
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_is_whitespace() {
|
||||
assert char::is_whitespace(' ');
|
||||
|
Loading…
Reference in New Issue
Block a user