From 761729900f04bd5f7065b41824d1300d47905ea2 Mon Sep 17 00:00:00 2001 From: Robert Garrett Date: Sat, 23 Aug 2025 10:08:08 -0500 Subject: [PATCH] Add unit tests card flipping in both directions --- src/card.rs | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/src/card.rs b/src/card.rs index 19d3bdf..73b82fc 100644 --- a/src/card.rs +++ b/src/card.rs @@ -302,6 +302,20 @@ pub const NW_TRIANGLE: [Cell; 9] = [ Cell::NW, Cell::Filled, Cell::Filled, ]; +#[rustfmt::skip] +pub const SW_TRIANGLE: [Cell; 9] = [ + Cell::SW, Cell::Filled, Cell::Filled, + Cell::Empty, Cell::SW, Cell::Filled, + Cell::Empty, Cell::Empty, Cell::SW, +]; + +#[rustfmt::skip] +pub const NE_TRIANGLE: [Cell; 9] = [ + Cell::NE, Cell::Empty, Cell::Empty, + Cell::Filled, Cell::NE, Cell::Empty, + Cell::Filled, Cell::Filled, Cell::NE +]; + #[rustfmt::skip] pub const OCTAGON: [Cell; 9] = [ Cell::NW, Cell::Filled, Cell::NE, @@ -573,12 +587,36 @@ mod test { #[test] fn flip_triangle_vertical() { - todo!(); + let tri = Card { + cells: NW_TRIANGLE, + ..Default::default() + }; + + let expected = Card { + cells: SW_TRIANGLE, + ..Default::default() + }; + + let result = tri.flip(FlipDir::Vertical); + + assert_eq!(result, expected); } #[test] fn flip_triangle_horizontal() { - todo!(); + let tri = Card { + cells: NW_TRIANGLE, + ..Default::default() + }; + + let expected = Card { + cells: NE_TRIANGLE, + ..Default::default() + }; + + let result = tri.flip(FlipDir::Horizontal); + + assert_eq!(result, expected); } #[test]