Skip to content

Commit

Permalink
Add a test for char ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
CAD97 committed May 21, 2020
1 parent 27d1cd8 commit b1d1f25
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/libcore/tests/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1932,6 +1932,16 @@ fn test_range() {
);
}

#[test]
fn test_char_range() {
use std::char;
assert!(('\0'..=char::MAX).eq((0..=char::MAX as u32).filter_map(char::from_u32)));
assert!(('\0'..=char::MAX).rev().eq((0..=char::MAX as u32).filter_map(char::from_u32).rev()));

assert_eq!(('\u{D7FF}'..='\u{E000}').count(), 2);
assert_eq!(('\u{D7FF}'..'\u{E000}').count(), 1);
}

#[test]
fn test_range_exhaustion() {
let mut r = 10..10;
Expand Down

0 comments on commit b1d1f25

Please sign in to comment.