Skip to content

Commit 26b54cc

Browse files
committed
Add asserts to char::is_upper and char::is_lower
Add an assert that the argument char is ASCII, as well as adding issue numbers to FIXMEs
1 parent f67f238 commit 26b54cc

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/libcore/char.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,21 +123,23 @@ pure fn to_digit(c: char, radix: uint) -> option<uint> {
123123
}
124124

125125
/*
126-
FIXME: works only on ASCII
126+
FIXME: works only on ASCII (Issue #1985)
127127
*/
128128
#[doc = "Convert a char to the corresponding lower case."]
129129
pure fn to_lower(c: char) -> char {
130+
assert is_ascii(c);
130131
alt c {
131132
'A' to 'Z' { ((c as u8) + 32u8) as char }
132133
_ { c }
133134
}
134135
}
135136

136137
/*
137-
FIXME: works only on ASCII
138+
FIXME: works only on ASCII (Issue 1985)
138139
*/
139140
#[doc = "Convert a char to the corresponding upper case."]
140141
pure fn to_upper(c: char) -> char {
142+
assert is_ascii(c);
141143
alt c {
142144
'a' to 'z' { ((c as u8) - 32u8) as char }
143145
_ { c }
@@ -208,16 +210,18 @@ fn test_to_digit() {
208210
fn test_to_lower() {
209211
assert (to_lower('H') == 'h');
210212
assert (to_lower('e') == 'e');
213+
// non-ASCII, shouldn't work (see earlier FIXME)
211214
//assert (to_lower('Ö') == 'ö');
212-
assert (to_lower('ß') == 'ß');
215+
//assert (to_lower('ß') == 'ß');
213216
}
214217

215218
#[test]
216219
fn test_to_upper() {
217220
assert (to_upper('l') == 'L');
218221
assert (to_upper('Q') == 'Q');
222+
// non-ASCII, shouldn't work (see earlier FIXME)
219223
//assert (to_upper('ü') == 'Ü');
220-
assert (to_upper('ß') == 'ß');
224+
//assert (to_upper('ß') == 'ß');
221225
}
222226

223227
#[test]

0 commit comments

Comments
 (0)