Add unit tests for transposition
This commit is contained in:
87
src/card.rs
87
src/card.rs
@@ -619,14 +619,97 @@ mod test {
|
|||||||
assert_eq!(result, expected);
|
assert_eq!(result, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Test transposition on column 1
|
||||||
#[test]
|
#[test]
|
||||||
fn transpose_vertical() {
|
fn transpose_vertical() {
|
||||||
todo!();
|
let left_shape = Card {
|
||||||
|
cells: OCTAGON,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
// It's a small NW triangle.
|
||||||
|
let right_shape = Card {
|
||||||
|
#[rustfmt::skip]
|
||||||
|
cells: [
|
||||||
|
Cell::Filled, Cell::Empty, Cell::Empty,
|
||||||
|
Cell::SE, Cell::Empty, Cell::NW,
|
||||||
|
Cell::Empty, Cell::NW, Cell::Filled,
|
||||||
|
],
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
let expected_left = Card {
|
||||||
|
#[rustfmt::skip]
|
||||||
|
cells: [
|
||||||
|
Cell::Filled, Cell::Filled, Cell::NE,
|
||||||
|
Cell::SE, Cell::Filled, Cell::Filled,
|
||||||
|
Cell::Empty, Cell::Filled, Cell::SE,
|
||||||
|
],
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
let expected_right = Card {
|
||||||
|
#[rustfmt::skip]
|
||||||
|
cells: [
|
||||||
|
Cell::NW, Cell::Empty, Cell::Empty,
|
||||||
|
Cell::Filled, Cell::Empty, Cell::NW,
|
||||||
|
Cell::SW, Cell::NW, Cell::Filled,
|
||||||
|
],
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
let (res_left, res_right) = left_shape.transpose(
|
||||||
|
right_shape,
|
||||||
|
TransposeSelection::Column(TransposeIndex::First),
|
||||||
|
);
|
||||||
|
assert_eq!(res_left, expected_left);
|
||||||
|
assert_eq!(res_right, expected_right);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Test transposition on row 3
|
||||||
#[test]
|
#[test]
|
||||||
fn transpose_horizontal() {
|
fn transpose_horizontal() {
|
||||||
todo!();
|
let left_shape = Card {
|
||||||
|
cells: OCTAGON,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
let right_shape = Card {
|
||||||
|
#[rustfmt::skip]
|
||||||
|
cells: [
|
||||||
|
Cell::Filled, Cell::Empty, Cell::Empty,
|
||||||
|
Cell::SE, Cell::Empty, Cell::NW,
|
||||||
|
Cell::Empty, Cell::NW, Cell::Filled,
|
||||||
|
],
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
let expected_left = Card {
|
||||||
|
#[rustfmt::skip]
|
||||||
|
cells: [
|
||||||
|
Cell::NW, Cell::Filled, Cell::NE,
|
||||||
|
Cell::Filled, Cell::Filled, Cell::Filled,
|
||||||
|
Cell::Empty, Cell::NW, Cell::Filled,
|
||||||
|
],
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
let expected_right = Card {
|
||||||
|
#[rustfmt::skip]
|
||||||
|
cells: [
|
||||||
|
Cell::Filled, Cell::Empty, Cell::Empty,
|
||||||
|
Cell::SE, Cell::Empty, Cell::NW,
|
||||||
|
Cell::SW, Cell::Filled, Cell::SE,
|
||||||
|
],
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
let (res_left, res_right) = left_shape.transpose(
|
||||||
|
right_shape,
|
||||||
|
TransposeSelection::Row(TransposeIndex::Third),
|
||||||
|
);
|
||||||
|
assert_eq!(res_left, expected_left);
|
||||||
|
assert_eq!(res_right, expected_right);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Reference in New Issue
Block a user