Add merge door tests
This commit is contained in:
56
src/card.rs
56
src/card.rs
@@ -191,6 +191,60 @@ mod test {
|
||||
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*
|
||||
/// they are opposites. See test [`merge_opposite_triangles()`].
|
||||
#[test]
|
||||
@@ -275,7 +329,7 @@ mod test {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn transpose_horizontal(){
|
||||
fn transpose_horizontal() {
|
||||
todo!();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user