From 46cfe439831ca0a676444842dd70018b03bdc562 Mon Sep 17 00:00:00 2001 From: Palash Tyagi <23239946+Magnus167@users.noreply.github.com> Date: Mon, 7 Jul 2025 21:30:26 +0100 Subject: [PATCH] Add tests for row access and row_copy_from_slice methods --- src/matrix/mat.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/matrix/mat.rs b/src/matrix/mat.rs index ceb693e..407675a 100644 --- a/src/matrix/mat.rs +++ b/src/matrix/mat.rs @@ -1205,6 +1205,21 @@ mod tests { assert_eq!(ma.row(1), &[10, 20, 30]); } + #[test] + #[should_panic(expected = "row index 3 out of bounds for 3 rows")] + fn test_row_out_of_bounds_index() { + let ma = static_test_matrix(); + ma.row(3); + } + + #[test] + #[should_panic(expected = "input slice length 2 does not match number of columns 3")] + fn test_row_copy_from_slice_wrong_length() { + let mut ma = static_test_matrix(); + let new_row = vec![10, 20]; // Only 2 elements, but row length is 3 + ma.row_copy_from_slice(1, &new_row); + } + #[test] fn test_shape() { let ma = static_test_matrix_2x4();