A few iterator tests
This commit is contained in:
parent
dfc9392c38
commit
096fb795de
@ -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]);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user