Cut triangle test

This commit is contained in:
Patrick Gelvin
2025-08-23 13:02:41 -07:00
committed by Robert Garrett
parent 4bf3c44b5e
commit d98b28cb36

View File

@@ -616,7 +616,108 @@ mod test {
#[test]
fn cut_triangle() {
todo!();
let tri = Card {
cells: NW_TRIANGLE,
..Default::default()
};
// Pairs of each different slice option
let vert_left_pair = (
Card {
#[rustfmt::skip]
cells: [
Cell::Empty, Cell::Empty, Cell::Empty,
Cell::Empty, Cell::Empty, Cell::Empty,
Cell::NW, Cell::Empty, Cell::Empty,
],
..Default::default()
},
Card {
#[rustfmt::skip]
cells: [
Cell::Empty, Cell::Empty, Cell::NW,
Cell::Empty, Cell::NW, Cell::Filled,
Cell::Empty, Cell::Filled, Cell::Filled,
],
..Default::default()
},
);
let vert_right_pair = (
Card {
#[rustfmt::skip]
cells: [
Cell::Empty, Cell::Empty, Cell::Empty,
Cell::Empty, Cell::NW, Cell::Empty,
Cell::NW, Cell::Filled, Cell::Empty,
],
..Default::default()
},
Card {
#[rustfmt::skip]
cells: [
Cell::Empty, Cell::Empty, Cell::NW,
Cell::Empty, Cell::Empty, Cell::Filled,
Cell::Empty, Cell::Empty, Cell::Filled,
],
..Default::default()
},
);
let horiz_top_pair = (
Card {
#[rustfmt::skip]
cells: [
Cell::Empty, Cell::Empty, Cell::NW,
Cell::Empty, Cell::Empty, Cell::Empty,
Cell::Empty, Cell::Empty, Cell::Empty,
],
..Default::default()
},
Card {
#[rustfmt::skip]
cells: [
Cell::Empty, Cell::Empty, Cell::Empty,
Cell::Empty, Cell::NW, Cell::Filled,
Cell::NW, Cell::Filled, Cell::Filled,
],
..Default::default()
},
);
let horiz_bottom_pair = (
Card {
#[rustfmt::skip]
cells: [
Cell::Empty, Cell::Empty, Cell::NW,
Cell::Empty, Cell::NW, Cell::Filled,
Cell::Empty, Cell::Empty, Cell::Empty,
],
..Default::default()
},
Card {
#[rustfmt::skip]
cells: [
Cell::Empty, Cell::Empty, Cell::Empty,
Cell::Empty, Cell::Empty, Cell::Empty,
Cell::NW, Cell::Filled, Cell::Filled,
],
..Default::default()
},
);
// Run tests
let result_vleft = tri.clone().cut(CutLine::VertLeft);
assert_eq!(result_vleft, vert_left_pair);
let result_vright = tri.clone().cut(CutLine::VertRight);
assert_eq!(result_vright, vert_right_pair);
let result_hupper = tri.clone().cut(CutLine::HorizUpper);
assert_eq!(result_hupper, horiz_top_pair);
let result_hlower = tri.cut(CutLine::HorizLower);
assert_eq!(result_hlower, horiz_bottom_pair);
}
#[test]