Compare commits

2 Commits

Author SHA1 Message Date
2024ad6e95 Outline more tests for the other Card methods 2025-08-22 19:22:48 -05:00
b3b8d1a814 Add unit tests for Card floor merging
Do some quick checks to make sure the merging function works the way we
expect. This also records how some edge cases will be handled, such as
merging two triangles.
2025-08-22 17:15:06 -07:00

View File

@@ -191,21 +191,101 @@ mod test {
assert!(extra_doors.is_none());
}
/// Merging two corner cells together results in the upper cell coming through.
/// Merging two triangular [`Cell`]s should prefer the top-most one, *unless*
/// they are opposites. See test [`merge_opposite_triangles()`].
#[test]
fn merge_triangle_and_triangle() {
todo!();
let mut top = Card::default();
top.cells[0] = Cell::NW;
let mut bottom = Card::default();
bottom.cells[0] = Cell::NE;
let expected = top.clone();
let (stacked, doors) = bottom.merge(top);
assert_eq!(stacked, expected);
assert!(doors.is_none());
}
/// Merging a filled cell with anything should result in [`Cell::Filled`].
#[test]
fn merge_triangle_and_filled() {
todo!();
let filled = Card {
cells: FULL_SQUARE,
..Default::default()
};
let triangle = Card {
cells: NW_TRIANGLE,
..Default::default()
};
let expected = filled.clone();
// Check the merge in both directions.
let result_fill_over_tri = triangle.merge(filled);
let result_tri_over_fill = filled.merge(triangle);
assert_eq!(expected, result_fill_over_tri.0);
assert_eq!(expected, result_tri_over_fill.0);
assert!(result_fill_over_tri.1.is_none());
assert!(result_tri_over_fill.1.is_none());
}
/// Merging a NW and SE cell should result in a single [`Cell::Filled`].
#[test]
fn merge_opposite_triangles() {
let mut top = Card::default();
top.cells[0] = Cell::NW;
let mut bottom = Card::default();
bottom.cells[0] = Cell::SE;
let mut expected = Card::default();
expected.cells[0] = Cell::Filled;
let (stacked, doors) = bottom.merge(top);
assert_eq!(stacked, expected);
assert!(doors.is_none());
}
#[test]
fn cut_octagon() {
todo!();
}
#[test]
fn cut_triangle() {
todo!();
}
#[test]
fn flip_triangle_vertical() {
todo!();
}
#[test]
fn flip_triangle_horizontal() {
todo!();
}
#[test]
fn transpose_vertical() {
todo!();
}
#[test]
fn transpose_horizontal(){
todo!();
}
#[test]
fn rotate_clockwise() {
todo!();
}
#[test]
fn rotate_counter_clockwise() {
todo!();
}
}