diff options
| author | Simon Sapin <simon.sapin@exyr.org> | 2017-07-06 18:13:44 +0200 |
|---|---|---|
| committer | Simon Sapin <simon.sapin@exyr.org> | 2017-07-08 08:55:55 +0200 |
| commit | e9a61eeb0434aabc1874c768eebc8bc7a68c6659 (patch) | |
| tree | 2d35333b01feb700cfbfd00302ee575a1d8719d8 /src/libcore/tests | |
| parent | 7a40307a7ca44d8ff4035c59022647cddc5b6699 (diff) | |
| download | rust-e9a61eeb0434aabc1874c768eebc8bc7a68c6659.tar.gz rust-e9a61eeb0434aabc1874c768eebc8bc7a68c6659.zip | |
Add tests for reaching the end of RangeInclusive as an iterator
Diffstat (limited to 'src/libcore/tests')
| -rw-r--r-- | src/libcore/tests/iter.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs index 748eac10ac0..a1249a5f22c 100644 --- a/src/libcore/tests/iter.rs +++ b/src/libcore/tests/iter.rs @@ -1077,6 +1077,26 @@ fn test_range() { } #[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)); assert_eq!((10..15).nth(1), Some(11)); |
