diff options
| author | blake2-ppc <blake2-ppc> | 2013-07-18 17:34:28 +0200 |
|---|---|---|
| committer | blake2-ppc <blake2-ppc> | 2013-07-20 20:24:00 +0200 |
| commit | ffe2623e47d9c5a5914865a9556cb1298ca00058 (patch) | |
| tree | 1137b4cc9766b6f639ddf9ca65cde584aa05c142 /src/libstd | |
| parent | 4623e81aa5429cf3b9b0837907b70da5e749facc (diff) | |
| download | rust-ffe2623e47d9c5a5914865a9556cb1298ca00058.tar.gz rust-ffe2623e47d9c5a5914865a9556cb1298ca00058.zip | |
iterator: Add test for .cycle()
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/iterator.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libstd/iterator.rs b/src/libstd/iterator.rs index ce1c1d585d1..198e63f83c6 100644 --- a/src/libstd/iterator.rs +++ b/src/libstd/iterator.rs @@ -1495,6 +1495,20 @@ mod tests { } #[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]; for uint::range(0, v.len()) |i| { |
