Skip to content

Commit d33cc12

Browse files
committed
Unit Tests
1 parent 5850f0b commit d33cc12

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/libcore/tests/iter.rs

+18
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,24 @@ fn test_iterator_step_by() {
161161
assert_eq!(it.next(), None);
162162
}
163163

164+
#[test]
165+
fn test_iterator_step_by_nth() {
166+
let mut it = (0..16).step_by(5);
167+
assert_eq!(it.nth(0), Some(0));
168+
assert_eq!(it.nth(0), Some(5));
169+
assert_eq!(it.nth(0), Some(10));
170+
assert_eq!(it.nth(0), Some(15));
171+
assert_eq!(it.nth(0), None);
172+
173+
let it = (0..18).step_by(5);
174+
assert_eq!(it.clone().nth(0), Some(0));
175+
assert_eq!(it.clone().nth(1), Some(5));
176+
assert_eq!(it.clone().nth(2), Some(10));
177+
assert_eq!(it.clone().nth(3), Some(15));
178+
assert_eq!(it.clone().nth(4), None);
179+
assert_eq!(it.clone().nth(42), None);
180+
}
181+
164182
#[test]
165183
#[should_panic]
166184
fn test_iterator_step_by_zero() {

0 commit comments

Comments
 (0)