Skip to content

Commit

Permalink
Added test that CircularTupleWindows clone works correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
zachs18 committed Mar 23, 2023
1 parent 39db89b commit 8d40ca9
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/tuples.rs
Expand Up @@ -61,6 +61,30 @@ fn tuple_windows() {
assert_eq!(None, iter.next());
}

#[test]
fn circular_tuple_windows() {
let v = [1, 2, 3, 4, 5];

let mut iter = v.iter().cloned().circular_tuple_windows();
assert_eq!(Some((1,)), iter.next());
assert_eq!(Some((2,)), iter.next());
assert_eq!(Some((3,)), iter.next());

let mut iter = v.iter().cloned().circular_tuple_windows();
assert_eq!(Some((1, 2, 3, 4)), iter.next());
assert_eq!(Some((2, 3, 4, 5)), iter.next());
// Testing impl Clone for CircularTupleWindows
let mut iter2 = iter.clone();
assert_eq!(Some((3, 4, 5, 1)), iter.next());
assert_eq!(Some((3, 4, 5, 1)), iter2.next());
assert_eq!(Some((4, 5, 1, 2)), iter.next());
assert_eq!(Some((4, 5, 1, 2)), iter2.next());
assert_eq!(Some((5, 1, 2, 3)), iter.next());
assert_eq!(Some((5, 1, 2, 3)), iter2.next());
assert_eq!(None, iter.next());
assert_eq!(None, iter2.next());
}

#[test]
fn next_tuple() {
let v = [1, 2, 3, 4, 5];
Expand Down

0 comments on commit 8d40ca9

Please sign in to comment.