Skip to content

Commit

Permalink
A few iterator tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jedestep authored and emberian committed Jun 26, 2013
1 parent dfc9392 commit 096fb79
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/libextra/deque.rs
Expand Up @@ -500,4 +500,35 @@ mod tests {
assert_eq!(capacity(&mut d.elts), 64);
}

#[test]
fn test_iter() {
let mut d = Deque::new();
for std::int::range(0,5) |i| {
d.add_back(i);
}
assert_eq!(d.iter().collect::<~[&int]>(),
~[&0,&1,&2,&3,&4]);

for std::int::range(6,9) |i| {
d.add_front(i);
}
assert_eq!(d.iter().collect::<~[&int]>(),
~[&8,&7,&6,&0,&1,&2,&3,&4]);
}

#[test]
fn test_rev_iter() {
let mut d = Deque::new();
for std::int::range(0,5) |i| {
d.add_back(i);
}
assert_eq!(d.rev_iter().collect::<~[&int]>(),
~[&4,&3,&2,&1,&0]);

for std::int::range(6,9) |i| {
d.add_front(i);
}
assert_eq!(d.rev_iter().collect::<~[&int]>(),
~[&4,&3,&2,&1,&0,&6,&7,&8]);
}
}

0 comments on commit 096fb79

Please sign in to comment.