diff --git a/tests/extensions/sequence.rs b/tests/extensions/sequence.rs index 86cfe73..e483b1e 100644 --- a/tests/extensions/sequence.rs +++ b/tests/extensions/sequence.rs @@ -18,6 +18,7 @@ where + UnwindSafe + Debug + 'a, + C::This<(i64, i64)>: FromIterator<(i64, i64)> + Equal + Debug, for<'c> &'c C: UnwindSafe, { // add_at @@ -507,23 +508,23 @@ where assert_vec_seq_equal(a.windowed_circular(2, 2), vec![vec![1, 2], vec![3, 1]]); assert_vec_seq_equal(e.windowed_circular(1, 1), vec![]); - // zip - FIXME - implement test - // let a = a_source.clone(); - // let e = e_source.clone(); - // assert_seq_equal(a.zip(vec![4, 5, 6]), vec![(1, 4), (2, 5), (3, 6)]); - // let a = a_source.clone(); - // assert_seq_equal(a.zip(vec![4, 5]), vec![(1, 4), (2, 5)]); - // let a = a_source.clone(); - // assert_seq_equal(a.zip(vec![4, 5, 6, 7]), vec![(1, 4), (2, 5), (3, 6)]); - // assert_seq_equal(e.zip(vec![1]), vec![]); + // zip + let a = a_source.clone(); + let e = e_source.clone(); + assert_seq_equal(a.zip(vec![4_i64, 5, 6]), vec![(1, 4), (2, 5), (3, 6)]); + let a = a_source.clone(); + assert_seq_equal(a.zip(vec![4_i64, 5]), vec![(1, 4), (2, 5)]); + let a = a_source.clone(); + assert_seq_equal(a.zip(vec![4_i64, 5, 6, 7]), vec![(1, 4), (2, 5), (3, 6)]); + assert_seq_equal(e.zip(vec![1_i64]), vec![]); - // zip_padded - FIXME - implement test - // let a = a_source.clone(); - // let e = e_source.clone(); - // assert_seq_equal(a.zip_padded(vec![4, 5, 6], || 1, || 2), vec![(1, 4), (2, 5), (3, 6)]); - // let a = a_source.clone(); - // assert_seq_equal(a.zip_padded(vec![4, 5, 6, 7], || 1, || 2), vec![(1, 4), (2, 5), (3, 6), (1, 7]); - // let a = a_source.clone(); - // assert_seq_equal(a.zip_padded(vec![4, 5], || 1, || 2), vec![(1, 4), (2, 5), (3, 2)]); - // assert_seq_equal(e.zip_padded(vec![1]), vec![(1, 1)]); + // zip_padded + let a = a_source.clone(); + let e = e_source.clone(); + assert_seq_equal(a.zip_padded(vec![4_i64, 5, 6], || 1, || 2), vec![(1, 4), (2, 5), (3, 6)]); + let a = a_source.clone(); + assert_seq_equal(a.zip_padded(vec![4_i64, 5, 6, 7], || 1, || 2), vec![(1, 4), (2, 5), (3, 6), (1, 7)]); + let a = a_source.clone(); + assert_seq_equal(a.zip_padded(vec![4_i64, 5], || 1, || 2), vec![(1, 4), (2, 5), (3, 2)]); + assert_seq_equal(e.zip_padded(vec![1_i64], || 1, || 2), vec![(1, 1)]); } diff --git a/tests/extensions/traits.rs b/tests/extensions/traits.rs index 9099967..5cb98c7 100644 --- a/tests/extensions/traits.rs +++ b/tests/extensions/traits.rs @@ -56,6 +56,7 @@ where + Debug + 'a, >::This: FromIterator + Default + Extend + Equal + Debug, + >::This<(i64, i64)>: FromIterator<(i64, i64)> + Equal + Debug, for<'c> &'c C: UnwindSafe, { test_traversable(true, a, b, e); @@ -83,6 +84,7 @@ where + Debug + 'a, >::This: FromIterator + Default + Extend + Equal + Debug, + >::This<(i64, i64)>: FromIterator<(i64, i64)> + Equal + Debug, for<'c> &'c C: UnwindSafe, { test_traversable(true, a, b, e); diff --git a/tests/extensions/util.rs b/tests/extensions/util.rs index 9226668..411228a 100644 --- a/tests/extensions/util.rs +++ b/tests/extensions/util.rs @@ -5,82 +5,54 @@ use std::hash::Hash; pub(crate) trait Equal { fn equal(&self, other: &Self) -> bool; - // - // fn compare(&self, other: &Self) -> Ordering; } impl Equal for i64 { fn equal(&self, other: &Self) -> bool { self == other } - // - // fn compare(&self, other: &Self) -> Ordering { - // self.cmp(other) - // } +} + +impl Equal for (i64, i64) { + fn equal(&self, other: &Self) -> bool { + self.0 == other.0 && self.1 == other.1 + } } impl Equal for [Item] { fn equal(&self, other: &Self) -> bool { self.iter().zip(other.iter()).all(|(x, y)| x.equal(y)) } - // - // fn compare(&self, other: &Self) -> Ordering { - // self.cmp(other) - // } } impl Equal for LinkedList { fn equal(&self, other: &Self) -> bool { self.iter().zip(other.iter()).all(|(x, y)| x.equal(y)) } - // - // fn compare(&self, other: &Self) -> Ordering { - // self.cmp(other) - // } } impl Equal for Vec { fn equal(&self, other: &Self) -> bool { self.iter().zip(other.iter()).all(|(x, y)| x.equal(y)) } - // - // fn compare(&self, other: &Self) -> Ordering { - // self.cmp(other) - // } } impl Equal for VecDeque { fn equal(&self, other: &Self) -> bool { self.iter().zip(other.iter()).all(|(x, y)| x.equal(y)) } - // - // fn compare(&self, other: &Self) -> Ordering { - // self.cmp(other) - // } } impl Equal for HashSet { fn equal(&self, other: &Self) -> bool { self == other } - // - // fn compare(&self, other: &Self) -> Ordering { - // let mut self_vec = Vec::from_iter(self.iter()); - // let mut other_vec = Vec::from_iter(other.iter()); - // self_vec.sort(); - // other_vec.sort(); - // self_vec.cmp(&other_vec) - // } } impl Equal for BTreeSet { fn equal(&self, other: &Self) -> bool { self == other } - // - // fn compare(&self, other: &Self) -> Ordering { - // self.cmp(other) - // } } impl Equal for BinaryHeap { @@ -89,42 +61,18 @@ impl Equal for BinaryHeap { let other_values: HashSet<&Item> = HashSet::from_iter(other.iter()); self_values == other_values } - // - // fn compare(&self, other: &Self) -> Ordering { - // let mut self_vec = Vec::from_iter(self.iter()); - // let mut other_vec = Vec::from_iter(other.iter()); - // self_vec.sort(); - // other_vec.sort(); - // self_vec.cmp(&other_vec) - // } } impl Equal for HashMap { fn equal(&self, other: &Self) -> bool { self == other } - // - // fn compare(&self, other: &Self) -> Ordering { - // let mut self_vec = Vec::from_iter(self); - // let mut other_vec = Vec::from_iter(other); - // self_vec.sort(); - // other_vec.sort(); - // self_vec.cmp(&other_vec) - // } } impl Equal for BTreeMap { fn equal(&self, other: &Self) -> bool { self == other } - // - // fn compare(&self, other: &Self) -> Ordering { - // let mut self_vec = Vec::from_iter(self); - // let mut other_vec = Vec::from_iter(other); - // self_vec.sort(); - // other_vec.sort(); - // self_vec.cmp(&other_vec) - // } } //noinspection RsUnresolvedPath