A few iterator tests

This commit is contained in:
Jed Estep 2013-06-26 10:04:44 -04:00 committed by Corey Richardson
parent dfc9392c38
commit 096fb795de

View File

@ -500,4 +500,35 @@ fn test_reserve_at_least() {
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]);
}
}