Skip to content

Commit

Permalink
Replace custom zip_eq test with quick test
Browse files Browse the repository at this point in the history
  • Loading branch information
kinto-b authored and Philippe-Cholet committed Apr 15, 2024
1 parent 37c54d1 commit 5be2e8d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
8 changes: 8 additions & 0 deletions tests/quick.rs
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
@@ -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();
}

0 comments on commit 5be2e8d

Please sign in to comment.