iterator: Add test for .cycle()
This commit is contained in:
parent
4623e81aa5
commit
ffe2623e47
1 changed files with 14 additions and 0 deletions
|
|
@ -1494,6 +1494,20 @@ mod tests {
|
|||
assert_eq!(i, 10);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_cycle() {
|
||||
let cycle_len = 3;
|
||||
let it = Counter::new(0u,1).take_(cycle_len).cycle();
|
||||
assert_eq!(it.size_hint(), (uint::max_value, None));
|
||||
for it.take_(100).enumerate().advance |(i, x)| {
|
||||
assert_eq!(i % cycle_len, x);
|
||||
}
|
||||
|
||||
let mut it = Counter::new(0u,1).take_(0).cycle();
|
||||
assert_eq!(it.size_hint(), (0, Some(0)));
|
||||
assert_eq!(it.next(), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_iterator_nth() {
|
||||
let v = &[0, 1, 2, 3, 4];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue