Skip to content

Commit

Permalink
Add tests for Iterator::copied()
Browse files Browse the repository at this point in the history
  • Loading branch information
KamilaBorowska committed Dec 5, 2018
1 parent fcc4604 commit fe45e9a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/libcore/tests/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,23 @@ fn test_rev() {
vec![16, 14, 12, 10, 8, 6]);
}

#[test]
fn test_copied() {
let xs = [2, 4, 6, 8];

let mut it = xs.iter().copied();
assert_eq!(it.len(), 4);
assert_eq!(it.next(), Some(2));
assert_eq!(it.len(), 3);
assert_eq!(it.next(), Some(4));
assert_eq!(it.len(), 2);
assert_eq!(it.next_back(), Some(8));
assert_eq!(it.len(), 1);
assert_eq!(it.next_back(), Some(6));
assert_eq!(it.len(), 0);
assert_eq!(it.next_back(), None);
}

#[test]
fn test_cloned() {
let xs = [2, 4, 6, 8];
Expand Down
1 change: 1 addition & 0 deletions src/libcore/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#![feature(flt2dec)]
#![feature(fmt_internals)]
#![feature(hashmap_internals)]
#![feature(iter_copied)]
#![feature(iter_unfold)]
#![feature(pattern)]
#![feature(range_is_empty)]
Expand Down

0 comments on commit fe45e9a

Please sign in to comment.