diff --git a/nalgebra-sparse/tests/unit_tests/csc.rs b/nalgebra-sparse/tests/unit_tests/csc.rs index b27f19be..534adb4f 100644 --- a/nalgebra-sparse/tests/unit_tests/csc.rs +++ b/nalgebra-sparse/tests/unit_tests/csc.rs @@ -375,4 +375,11 @@ proptest! { prop_assert_eq!(d_entries, csc_diagonal_entries); } + + #[test] + fn csc_identity(n in 0 ..= 6usize) { + let csc = CscMatrix::::identity(n); + prop_assert_eq!(csc.nnz(), n); + prop_assert_eq!(DMatrix::from(&csc), DMatrix::identity(n, n)); + } } diff --git a/nalgebra-sparse/tests/unit_tests/csr.rs b/nalgebra-sparse/tests/unit_tests/csr.rs index 2de93e51..d1e62bed 100644 --- a/nalgebra-sparse/tests/unit_tests/csr.rs +++ b/nalgebra-sparse/tests/unit_tests/csr.rs @@ -375,4 +375,11 @@ proptest! { prop_assert_eq!(d_entries, csr_diagonal_entries); } + + #[test] + fn csr_identity(n in 0 ..= 6usize) { + let csr = CsrMatrix::::identity(n); + prop_assert_eq!(csr.nnz(), n); + prop_assert_eq!(DMatrix::from(&csr), DMatrix::identity(n, n)); + } }