forked from M-Labs/nalgebra
Refactor unit tests
This commit is contained in:
parent
9a38c554af
commit
e227dd693e
@ -95,16 +95,30 @@ fn coo_triplets_iter_mut() {
|
|||||||
let v = vec![2, 3, 4, 7, 1, 3, 1, 5];
|
let v = vec![2, 3, 4, 7, 1, 3, 1, 5];
|
||||||
let mut coo =
|
let mut coo =
|
||||||
CooMatrix::<i32>::try_from_triplets(3, 5, i.clone(), j.clone(), v.clone()).unwrap();
|
CooMatrix::<i32>::try_from_triplets(3, 5, i.clone(), j.clone(), v.clone()).unwrap();
|
||||||
coo.triplet_iter_mut().for_each(|(_i, _j, v)| *v = *v * *v);
|
|
||||||
|
let actual_triplets: Vec<_> = coo.triplet_iter_mut().map(|(i, j, v)| (i, j, *v)).collect();
|
||||||
|
|
||||||
let expected_triplets: Vec<_> = i
|
let expected_triplets: Vec<_> = i
|
||||||
.iter()
|
.iter()
|
||||||
.zip(&j)
|
.zip(&j)
|
||||||
.zip(&v)
|
.zip(&v)
|
||||||
.map(|((i, j), v)| (*i, *j, v * v))
|
.map(|((i, j), v)| (*i, *j, *v))
|
||||||
.collect();
|
.collect();
|
||||||
let actual_triplets: Vec<_> = coo.triplet_iter().map(|(i, j, v)| (i, j, *v)).collect();
|
assert_eq!(expected_triplets, actual_triplets);
|
||||||
assert_eq!(expected_triplets, actual_triplets)
|
|
||||||
|
for (_i, _j, v) in coo.triplet_iter_mut() {
|
||||||
|
*v += *v;
|
||||||
|
}
|
||||||
|
|
||||||
|
let actual_triplets: Vec<_> = coo.triplet_iter_mut().map(|(i, j, v)| (i, j, *v)).collect();
|
||||||
|
let v = vec![4, 6, 8, 14, 2, 6, 2, 10];
|
||||||
|
let expected_triplets: Vec<_> = i
|
||||||
|
.iter()
|
||||||
|
.zip(&j)
|
||||||
|
.zip(&v)
|
||||||
|
.map(|((i, j), v)| (*i, *j, *v))
|
||||||
|
.collect();
|
||||||
|
assert_eq!(expected_triplets, actual_triplets);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
Loading…
Reference in New Issue
Block a user