Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Ockajak committed Jul 19, 2024
1 parent c97830f commit 0f75f89
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 76 deletions.
37 changes: 19 additions & 18 deletions tests/extensions/sequence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ where
+ UnwindSafe
+ Debug
+ 'a,
C::This<(i64, i64)>: FromIterator<(i64, i64)> + Equal + Debug,
for<'c> &'c C: UnwindSafe,
{
// add_at
Expand Down Expand Up @@ -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)]);
}
2 changes: 2 additions & 0 deletions tests/extensions/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ where
+ Debug
+ 'a,
<C as Collectible<i64>>::This<i64>: FromIterator<i64> + Default + Extend<i64> + Equal + Debug,
<C as Sequence<i64>>::This<(i64, i64)>: FromIterator<(i64, i64)> + Equal + Debug,
for<'c> &'c C: UnwindSafe,
{
test_traversable(true, a, b, e);
Expand Down Expand Up @@ -83,6 +84,7 @@ where
+ Debug
+ 'a,
<C as Collectible<i64>>::This<i64>: FromIterator<i64> + Default + Extend<i64> + Equal + Debug,
<C as Sequence<i64>>::This<(i64, i64)>: FromIterator<(i64, i64)> + Equal + Debug,
for<'c> &'c C: UnwindSafe,
{
test_traversable(true, a, b, e);
Expand Down
64 changes: 6 additions & 58 deletions tests/extensions/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Item: Equal> 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<Item: Equal> Equal for LinkedList<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<Item: Equal> Equal for Vec<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<Item: Equal> Equal for VecDeque<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<Item: Eq + Hash + Clone> Equal for HashSet<Item> {
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<Item: PartialEq> Equal for BTreeSet<Item> {
fn equal(&self, other: &Self) -> bool {
self == other
}
//
// fn compare(&self, other: &Self) -> Ordering {
// self.cmp(other)
// }
}

impl<Item: Eq + Hash + Clone> Equal for BinaryHeap<Item> {
Expand All @@ -89,42 +61,18 @@ impl<Item: Eq + Hash + Clone> Equal for BinaryHeap<Item> {
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<Key: Eq + Hash, Value: PartialEq> Equal for HashMap<Key, Value> {
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<Key: PartialEq, Value: PartialEq> Equal for BTreeMap<Key, Value> {
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
Expand Down

0 comments on commit 0f75f89

Please sign in to comment.