Add merge door tests

This commit is contained in:
Patrick Gelvin
2025-08-22 17:37:19 -07:00
parent 205111d25f
commit daf05e3609

View File

@@ -191,6 +191,60 @@ mod test {
assert!(extra_doors.is_none()); assert!(extra_doors.is_none());
} }
#[test]
fn check_merge_doors() {
let bottom = Card {
cells: NW_TRIANGLE,
s: true, // Test that this is not overwritten by an empty tile
se: true, // Test that this is subsumed by another door
e: true, // Test that this is popped off into the second card
..Default::default()
};
let top = Card {
cells: [
Cell::Empty,
Cell::Empty,
Cell::Empty,
Cell::Empty,
Cell::Empty,
Cell::Filled,
Cell::Empty,
Cell::Empty,
Cell::Filled,
],
se: true, // Test that this is subsumed by another door
n: true, // Test that is is dropped because no floor
..Default::default()
};
let expected = Card {
cells: [
Cell::Empty,
Cell::Empty,
Cell::NW,
Cell::Empty,
Cell::NW,
Cell::Filled,
Cell::NW,
Cell::Filled,
Cell::Filled,
],
s: true,
se: true,
..Default::default()
};
let expected_doors = Card {
e: true,
..Default::default()
};
let (stacked, extra_doors) = bottom.merge(top);
assert_eq!(stacked, expected);
assert_eq!(extra_doors, Some(expected_doors));
}
/// Merging two triangular [`Cell`]s should prefer the top-most one, *unless* /// Merging two triangular [`Cell`]s should prefer the top-most one, *unless*
/// they are opposites. See test [`merge_opposite_triangles()`]. /// they are opposites. See test [`merge_opposite_triangles()`].
#[test] #[test]
@@ -275,10 +329,10 @@ mod test {
} }
#[test] #[test]
fn transpose_horizontal(){ fn transpose_horizontal() {
todo!(); todo!();
} }
#[test] #[test]
fn rotate_clockwise() { fn rotate_clockwise() {
todo!(); todo!();