Skip to content

Commit f0eeb0d

Browse files
committed
Replace custom test with quick test
1 parent 18e352d commit f0eeb0d

File tree

2 files changed

+15
-37
lines changed

2 files changed

+15
-37
lines changed

tests/quick.rs

+15
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,21 @@ quickcheck! {
571571
let b = &b[..len];
572572
itertools::equal(zip_eq(a, b), zip(a, b))
573573
}
574+
575+
#[should_panic]
576+
fn zip_eq_panics(a: Vec<u8>, b: Vec<u8>) -> TestResult {
577+
if a.len() == b.len() { return TestResult::discard(); }
578+
zip_eq(a.iter(), b.iter()).count();
579+
TestResult::passed() // won't come here
580+
}
581+
582+
#[should_panic]
583+
fn zip_eq_fold_panics(a: Vec<u8>, b: Vec<u8>) -> TestResult {
584+
if a.len() == b.len() { return TestResult::discard(); }
585+
zip_eq(a.iter(), b.iter()).fold((), |_, _| ());
586+
TestResult::passed() // won't come here
587+
}
588+
574589
fn equal_positions(a: Vec<i32>) -> bool {
575590
let with_pos = a.iter().positions(|v| v % 2 == 0);
576591
let without = a.iter().enumerate().filter(|(_, v)| *v % 2 == 0).map(|(i, _)| i);

tests/zip.rs

-37
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use itertools::free::zip_eq;
21
use itertools::multizip;
32
use itertools::EitherOrBoth::{Both, Left, Right};
43
use itertools::Itertools;
@@ -55,39 +54,3 @@ fn test_double_ended_zip() {
5554
assert_eq!(it.next_back(), Some((1, 1)));
5655
assert_eq!(it.next_back(), None);
5756
}
58-
59-
#[should_panic]
60-
#[test]
61-
fn zip_eq_panic1() {
62-
let a = [1, 2];
63-
let b = [1, 2, 3];
64-
65-
zip_eq(&a, &b).count();
66-
}
67-
68-
#[should_panic]
69-
#[test]
70-
fn zip_eq_panic2() {
71-
let a: [i32; 0] = [];
72-
let b = [1, 2, 3];
73-
74-
zip_eq(&a, &b).count();
75-
}
76-
77-
#[should_panic]
78-
#[test]
79-
fn zip_eq_panic3() {
80-
let a = [1, 2];
81-
let b = [1, 2, 3];
82-
83-
zip_eq(&a, &b).fold(0, |acc, (x, y)| acc + x * y);
84-
}
85-
86-
#[should_panic]
87-
#[test]
88-
fn zip_eq_panic4() {
89-
let b = [1, 2];
90-
let a = [1, 2, 3];
91-
92-
zip_eq(&a, &b).fold(0, |acc, (x, y)| acc + x * y);
93-
}

0 commit comments

Comments
 (0)