From d7f8894ac016889494c7cfe707a85598e153c28c Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Sun, 4 Aug 2024 17:28:21 +0200 Subject: [PATCH] test(matrix): test Matrix::flip_* with non square matrices --- tests/matrix.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/matrix.rs b/tests/matrix.rs index 2325cbe1..23d7f3c9 100644 --- a/tests/matrix.rs +++ b/tests/matrix.rs @@ -211,7 +211,7 @@ fn no_rows_rotated_twice() { } #[test] -fn flip() { +fn flip_square() { let m1 = Matrix::square_from_vec(vec![0, 1, 2, 3]).unwrap(); let m2 = Matrix::square_from_vec(vec![1, 0, 3, 2]).unwrap(); let m3 = Matrix::square_from_vec(vec![2, 3, 0, 1]).unwrap(); @@ -224,6 +224,15 @@ fn flip() { assert_eq!(m1.flipped_ud(), m3); } +#[test] +fn flip_non_square() { + let m1 = Matrix::from_vec(2, 3, vec![0, 1, 2, 3, 4, 5]).unwrap(); + let m2 = Matrix::from_vec(2, 3, vec![3, 4, 5, 0, 1, 2]).unwrap(); + let m3 = Matrix::from_vec(2, 3, vec![2, 1, 0, 5, 4, 3]).unwrap(); + assert_eq!(m1.flipped_ud(), m2); + assert_eq!(m1.flipped_lr(), m3); +} + #[test] fn transpose() { let m1 = Matrix::from_vec(2, 3, vec![0, 1, 2, 3, 4, 5]).unwrap();