diff options
| author | oberien <jaro.fietz@gmx.de> | 2018-01-19 14:55:34 +0100 |
|---|---|---|
| committer | oberien <jaro.fietz@gmx.de> | 2018-01-19 14:55:34 +0100 |
| commit | d33cc12eed3df459db3c9ae2dd89df9cc6e45dd6 (patch) | |
| tree | e88d016b11cb7b70974510e3b282f344fa6fda22 /src/libcore/tests | |
| parent | 5850f0b742430a1b1b5ae7d2491dce6ca10e20d3 (diff) | |
| download | rust-d33cc12eed3df459db3c9ae2dd89df9cc6e45dd6.tar.gz rust-d33cc12eed3df459db3c9ae2dd89df9cc6e45dd6.zip | |
Unit Tests
Diffstat (limited to 'src/libcore/tests')
| -rw-r--r-- | src/libcore/tests/iter.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs index 8997cf9c6bf..e8874991659 100644 --- a/src/libcore/tests/iter.rs +++ b/src/libcore/tests/iter.rs @@ -162,6 +162,24 @@ fn test_iterator_step_by() { } #[test] +fn test_iterator_step_by_nth() { + let mut it = (0..16).step_by(5); + assert_eq!(it.nth(0), Some(0)); + assert_eq!(it.nth(0), Some(5)); + assert_eq!(it.nth(0), Some(10)); + assert_eq!(it.nth(0), Some(15)); + assert_eq!(it.nth(0), None); + + let it = (0..18).step_by(5); + assert_eq!(it.clone().nth(0), Some(0)); + assert_eq!(it.clone().nth(1), Some(5)); + assert_eq!(it.clone().nth(2), Some(10)); + assert_eq!(it.clone().nth(3), Some(15)); + assert_eq!(it.clone().nth(4), None); + assert_eq!(it.clone().nth(42), None); +} + +#[test] #[should_panic] fn test_iterator_step_by_zero() { let mut it = (0..).step_by(0); |
