Skip to content

Commit

Permalink
Add a specific test for FlatMap::fold
Browse files Browse the repository at this point in the history
  • Loading branch information
cuviper committed Sep 15, 2017
1 parent 61a7703 commit 351f56a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/libcore/tests/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,22 @@ fn test_iterator_flat_map() {
assert_eq!(i, ys.len());
}

/// Test `FlatMap::fold` with items already picked off the front and back,
/// to make sure all parts of the `FlatMap` are folded correctly.
#[test]
fn test_iterator_flat_map_fold() {
let xs = [0, 3, 6];
let ys = [1, 2, 3, 4, 5, 6, 7];
let mut it = xs.iter().flat_map(|&x| x..x+3);
it.next();
it.next_back();
let i = it.fold(0, |i, x| {
assert_eq!(x, ys[i]);
i + 1
});
assert_eq!(i, ys.len());
}

#[test]
fn test_inspect() {
let xs = [1, 2, 3, 4];
Expand Down

0 comments on commit 351f56a

Please sign in to comment.