Add tests for Csr/CscMatrix::identity

This commit is contained in:
Andreas Longva 2021-02-01 08:52:13 +01:00
parent 2d11b90149
commit 0936c4fad9
2 changed files with 14 additions and 0 deletions

View File

@ -375,4 +375,11 @@ proptest! {
prop_assert_eq!(d_entries, csc_diagonal_entries);
}
#[test]
fn csc_identity(n in 0 ..= 6usize) {
let csc = CscMatrix::<i32>::identity(n);
prop_assert_eq!(csc.nnz(), n);
prop_assert_eq!(DMatrix::from(&csc), DMatrix::identity(n, n));
}
}

View File

@ -375,4 +375,11 @@ proptest! {
prop_assert_eq!(d_entries, csr_diagonal_entries);
}
#[test]
fn csr_identity(n in 0 ..= 6usize) {
let csr = CsrMatrix::<i32>::identity(n);
prop_assert_eq!(csr.nnz(), n);
prop_assert_eq!(DMatrix::from(&csr), DMatrix::identity(n, n));
}
}