Skip to content

Commit

Permalink
Merge pull request #572 from evenfurther/add-tests
Browse files Browse the repository at this point in the history
test(matrix): test Matrix::flip_* with non square matrices
  • Loading branch information
samueltardieu authored Aug 4, 2024
2 parents 05d1264 + d7f8894 commit 9ba190d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,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();
Expand All @@ -250,6 +250,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();
Expand Down

0 comments on commit 9ba190d

Please sign in to comment.