Add test for row_copy_from_slice to check out-of-bounds access

This commit is contained in:
Palash Tyagi 2025-07-12 00:55:27 +01:00
parent 10018f7efe
commit a3bb509202

View File

@ -1250,6 +1250,13 @@ mod tests {
ma.row_copy_from_slice(1, &new_row); ma.row_copy_from_slice(1, &new_row);
assert_eq!(ma.row(1), &[10, 20, 30]); assert_eq!(ma.row(1), &[10, 20, 30]);
} }
#[test]
#[should_panic(expected = "row index 4 out of bounds for 3 rows")]
fn test_row_copy_from_slice_out_of_bounds() {
let mut ma = static_test_matrix();
let new_row = vec![10, 20, 30];
ma.row_copy_from_slice(4, &new_row);
}
#[test] #[test]
#[should_panic(expected = "row index 3 out of bounds for 3 rows")] #[should_panic(expected = "row index 3 out of bounds for 3 rows")]