mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Add tests for reaching the end of RangeInclusive as an iterator
This commit is contained in:
parent
7a40307a7c
commit
e9a61eeb04
@ -1076,6 +1076,26 @@ fn test_range() {
|
||||
(isize::MAX as usize + 2, Some(isize::MAX as usize + 2)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_range_inclusive_exhaustion() {
|
||||
let mut r = 10...10;
|
||||
assert_eq!(r.next(), Some(10));
|
||||
assert_eq!(r, 1...0);
|
||||
|
||||
let mut r = 10...10;
|
||||
assert_eq!(r.next_back(), Some(10));
|
||||
assert_eq!(r, 1...0);
|
||||
|
||||
let mut r = 10...12;
|
||||
assert_eq!(r.nth(2), Some(12));
|
||||
assert_eq!(r, 1...0);
|
||||
|
||||
let mut r = 10...12;
|
||||
assert_eq!(r.nth(5), None);
|
||||
assert_eq!(r, 1...0);
|
||||
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_range_nth() {
|
||||
assert_eq!((10..15).nth(0), Some(10));
|
||||
|
Loading…
Reference in New Issue
Block a user