Skip to content

Commit

Permalink
test(matrix): test Matrix::flip_* with non square matrices
Browse files Browse the repository at this point in the history
  • Loading branch information
samueltardieu committed Aug 4, 2024
1 parent 01abbab commit d7f8894
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 @@ -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();
Expand All @@ -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();
Expand Down

0 comments on commit d7f8894

Please sign in to comment.