Skip to content

Commit 6488324

Browse files
committed
std::ascii: Add tests for is_digit() and is_control()
1 parent 7b96f13 commit 6488324

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/libstd/ascii.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,15 @@ mod tests {
498498
assert_eq!('`'.to_ascii().to_upper().to_char(), '`');
499499
assert_eq!('{'.to_ascii().to_upper().to_char(), '{');
500500

501+
assert!('0'.to_ascii().is_digit());
502+
assert!('9'.to_ascii().is_digit());
503+
assert!(!'/'.to_ascii().is_digit());
504+
assert!(!':'.to_ascii().is_digit());
505+
506+
assert!((0x1fu8).to_ascii().is_control());
507+
assert!(!' '.to_ascii().is_control());
508+
assert!((0x7fu8).to_ascii().is_control());
509+
501510
assert!("banana".chars().all(|c| c.is_ascii()));
502511
assert!(!"ประเทศไทย中华Việt Nam".chars().all(|c| c.is_ascii()));
503512
}

0 commit comments

Comments
 (0)