Skip to content
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

Do not implement ZipEq::fold (and change test) #915

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions tests/quick.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,14 @@ quickcheck! {
let b = &b[..len];
itertools::equal(zip_eq(a, b), zip(a, b))
}

#[should_panic]
fn zip_eq_panics(a: Vec<u8>, b: Vec<u8>) -> TestResult {
if a.len() == b.len() { return TestResult::discard(); }
zip_eq(a.iter(), b.iter()).for_each(|_| {});
TestResult::passed() // won't come here
}

fn equal_positions(a: Vec<i32>) -> bool {
let with_pos = a.iter().positions(|v| v % 2 == 0);
let without = a.iter().enumerate().filter(|(_, v)| *v % 2 == 0).map(|(i, _)| i);
Expand Down
19 changes: 0 additions & 19 deletions tests/zip.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use itertools::free::zip_eq;
use itertools::multizip;
use itertools::EitherOrBoth::{Both, Left, Right};
use itertools::Itertools;
Expand Down Expand Up @@ -55,21 +54,3 @@ fn test_double_ended_zip() {
assert_eq!(it.next_back(), Some((1, 1)));
assert_eq!(it.next_back(), None);
}

#[should_panic]
#[test]
fn zip_eq_panic1() {
let a = [1, 2];
let b = [1, 2, 3];

zip_eq(&a, &b).count();
}

#[should_panic]
#[test]
fn zip_eq_panic2() {
let a: [i32; 0] = [];
let b = [1, 2, 3];

zip_eq(&a, &b).count();
}