File tree Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,26 @@ import is_alphabetic = unicode::derived_property::Alphabetic;
4141import is_XID_start = unicode:: derived_property:: XID_Start ;
4242import is_XID_continue = unicode:: derived_property:: XID_Continue ;
4343
44+ /*
45+ Function: is_lowercase
46+
47+ Indicates whether a character is in lower case, defined in terms of the
48+ Unicode General Category 'Ll'.
49+ */
50+ pure fn is_lowercase ( c : char ) -> bool {
51+ ret unicode:: general_category:: Ll ( c) ;
52+ }
53+
54+ /*
55+ Function: is_uppercase
56+
57+ Indicates whether a character is in upper case, defined in terms of the
58+ Unicode General Category 'Lu'.
59+ */
60+ pure fn is_uppercase ( c : char ) -> bool {
61+ ret unicode:: general_category:: Lu ( c) ;
62+ }
63+
4464/*
4565Function: is_whitespace
4666
@@ -126,4 +146,4 @@ pure fn cmp(a: char, b: char) -> int {
126146 ret if b > a { -1 }
127147 else if b < a { 1 }
128148 else { 0 }
129- }
149+ }
Original file line number Diff line number Diff line change @@ -3,6 +3,24 @@ import core::*;
33use std;
44import char;
55
6+ #[ test]
7+ fn test_is_lowercase ( ) {
8+ assert char:: is_lowercase ( 'a' ) ;
9+ assert char:: is_lowercase ( 'ö' ) ;
10+ assert char:: is_lowercase ( 'ß' ) ;
11+ assert !char:: is_lowercase ( 'Ü' ) ;
12+ assert !char:: is_lowercase ( 'P' ) ;
13+ }
14+
15+ #[ test]
16+ fn test_is_uppercase ( ) {
17+ assert !char:: is_uppercase ( 'h' ) ;
18+ assert !char:: is_uppercase ( 'ä' ) ;
19+ assert !char:: is_uppercase ( 'ß' ) ;
20+ assert char:: is_uppercase ( 'Ö' ) ;
21+ assert char:: is_uppercase ( 'T' ) ;
22+ }
23+
624#[ test]
725fn test_is_whitespace ( ) {
826 assert char:: is_whitespace ( ' ' ) ;
You can’t perform that action at this time.
0 commit comments