Skip to content

Rollup a bunch of smaller PRs #7417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 22 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
A few iterator tests
  • Loading branch information
jedestep authored and emberian committed Jun 26, 2013
commit 096fb795de0c194b439a9e332ca30d3d5886ddbb
31 changes: 31 additions & 0 deletions src/libextra/deque.rs
Original file line number Diff line number Diff line change
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]);
}
}