Skip to content

Commit 9531e52

Browse files
committed
test passed
1 parent f4b4290 commit 9531e52

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

quickcheck renamed to loop_test

File renamed without changes.

src/tests.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,21 @@ fn qc_distance_consistency(s: Vec<char>, t: Vec<char>) {
132132
assert_eq!(dist, y);
133133
}
134134

135+
#[quickcheck]
136+
fn qc_check_equality(s: Vec<usize>, t: Vec<usize>) {
137+
let (a, b) = diff(&s, &t);
138+
assert_eq!(s.len(), a.len());
139+
let check = |s: &[_], t: &[_], a: &[_]| {
140+
for (&si, &j) in s.iter().zip(a.iter()) {
141+
if let Some(j) = j {
142+
assert_eq!(si, t[j]);
143+
}
144+
}
145+
};
146+
check(&s, &t, &a);
147+
check(&t, &s, &b);
148+
}
149+
135150
pub fn slow_ratio<A: PartialEq<B>, B>(a: &[A], b: &[B]) -> f64 {
136151
let l = a.len() + b.len();
137152
if l == 0 {
@@ -167,7 +182,7 @@ fn qc_ratio_with_slow(s: Vec<char>, t: Vec<char>) {
167182
case("abc", "abd", 66.66666667),
168183
case("abc", "abddddd", 40.)
169184
)]
170-
fn test_ratio(s: &str, t: &str, expected: f64) {
185+
fn hm_ratio(s: &str, t: &str, expected: f64) {
171186
let ret = ratio(
172187
&s.chars().collect::<Vec<_>>(),
173188
&t.chars().collect::<Vec<_>>(),

0 commit comments

Comments
 (0)