|
|
|
@ -2,7 +2,7 @@ use super::*;
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn test_shape_layout_01a() {
|
|
|
|
fn test_shape_layout_01a() {
|
|
|
|
let actual = ShapeLayout(vec![vec![0, 1, 0], vec![1, 1, 1]]).positions();
|
|
|
|
let actual = ShapeLayout::new(vec![vec![0, 1, 0], vec![1, 1, 1]]).positions(Orientation::Up);
|
|
|
|
|
|
|
|
|
|
|
|
let expected: [RelativePosition; 4] =
|
|
|
|
let expected: [RelativePosition; 4] =
|
|
|
|
[(-1, 0).into(), (0, 0).into(), (1, 0).into(), (0, 1).into()];
|
|
|
|
[(-1, 0).into(), (0, 0).into(), (1, 0).into(), (0, 1).into()];
|
|
|
|
@ -12,7 +12,8 @@ fn test_shape_layout_01a() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn test_shape_layout_01b() {
|
|
|
|
fn test_shape_layout_01b() {
|
|
|
|
let actual = ShapeLayout(vec![vec![1, 0], vec![1, 1], vec![1, 0]]).positions();
|
|
|
|
let actual =
|
|
|
|
|
|
|
|
ShapeLayout::new(vec![vec![1, 0], vec![1, 1], vec![1, 0]]).positions(Orientation::Up);
|
|
|
|
|
|
|
|
|
|
|
|
let expected: [RelativePosition; 4] =
|
|
|
|
let expected: [RelativePosition; 4] =
|
|
|
|
[(0, -1).into(), (0, 0).into(), (1, 0).into(), (0, 1).into()];
|
|
|
|
[(0, -1).into(), (0, 0).into(), (1, 0).into(), (0, 1).into()];
|
|
|
|
@ -20,9 +21,20 @@ fn test_shape_layout_01b() {
|
|
|
|
debug_assert_eq!(expected, actual);
|
|
|
|
debug_assert_eq!(expected, actual);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
|
|
|
fn test_shape_layout_01c() {
|
|
|
|
|
|
|
|
let actual = ShapeLayout::new(vec![vec![0, 1, 0], vec![1, 1, 1]]).positions(Orientation::Down);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let expected: [RelativePosition; 4] =
|
|
|
|
|
|
|
|
[(0, -1).into(), (-1, 0).into(), (0, 0).into(), (1, 0).into(),];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
debug_assert_eq!(expected, actual);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn test_shape_layout_02a() {
|
|
|
|
fn test_shape_layout_02a() {
|
|
|
|
let actual = ShapeLayout(vec![vec![1], vec![1], vec![1], vec![1]]).positions();
|
|
|
|
let actual =
|
|
|
|
|
|
|
|
ShapeLayout::new(vec![vec![1], vec![1], vec![1], vec![1]]).positions(Orientation::Up);
|
|
|
|
|
|
|
|
|
|
|
|
let expected: [RelativePosition; 4] =
|
|
|
|
let expected: [RelativePosition; 4] =
|
|
|
|
[(0, -1).into(), (0, 0).into(), (0, 1).into(), (0, 2).into()];
|
|
|
|
[(0, -1).into(), (0, 0).into(), (0, 1).into(), (0, 2).into()];
|
|
|
|
@ -32,7 +44,7 @@ fn test_shape_layout_02a() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn test_shape_layout_02b() {
|
|
|
|
fn test_shape_layout_02b() {
|
|
|
|
let actual = ShapeLayout(vec![vec![1, 1, 1, 1]]).positions();
|
|
|
|
let actual = ShapeLayout::new(vec![vec![1, 1, 1, 1]]).positions(Orientation::Up);
|
|
|
|
|
|
|
|
|
|
|
|
let expected: [RelativePosition; 4] =
|
|
|
|
let expected: [RelativePosition; 4] =
|
|
|
|
[(-1, 0).into(), (0, 0).into(), (1, 0).into(), (2, 0).into()];
|
|
|
|
[(-1, 0).into(), (0, 0).into(), (1, 0).into(), (2, 0).into()];
|
|
|
|
@ -42,7 +54,7 @@ fn test_shape_layout_02b() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn test_shape_layout_03() {
|
|
|
|
fn test_shape_layout_03() {
|
|
|
|
let actual = ShapeLayout(vec![vec![1, 1, 0], vec![0, 1, 1]]).positions();
|
|
|
|
let actual = ShapeLayout::new(vec![vec![1, 1, 0], vec![0, 1, 1]]).positions(Orientation::Up);
|
|
|
|
|
|
|
|
|
|
|
|
let expected: [RelativePosition; 4] =
|
|
|
|
let expected: [RelativePosition; 4] =
|
|
|
|
[(0, 0).into(), (1, 0).into(), (-1, 1).into(), (0, 1).into()];
|
|
|
|
[(0, 0).into(), (1, 0).into(), (-1, 1).into(), (0, 1).into()];
|
|
|
|
@ -52,28 +64,29 @@ fn test_shape_layout_03() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn test_rotation_01() {
|
|
|
|
fn test_rotation_01() {
|
|
|
|
let actual = ShapeLayout(vec![vec![1], vec![1], vec![1], vec![1]]).rotated(Orientation::Left);
|
|
|
|
let actual =
|
|
|
|
|
|
|
|
ShapeLayout::new(vec![vec![1], vec![1], vec![1], vec![1]]).positions(Orientation::Left);
|
|
|
|
|
|
|
|
|
|
|
|
let expected = ShapeLayout(vec![vec![1, 1, 1, 1]]);
|
|
|
|
let expected = ShapeLayout::new(vec![vec![1, 1, 1, 1]]).positions(Orientation::Up);
|
|
|
|
|
|
|
|
|
|
|
|
debug_assert_eq!(expected, actual);
|
|
|
|
debug_assert_eq!(expected, actual);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn test_rotation_02() {
|
|
|
|
fn test_rotation_02() {
|
|
|
|
let base = ShapeLayout(vec![vec![0, 1, 0], vec![1, 1, 1]]);
|
|
|
|
let base = ShapeLayout::new(vec![vec![0, 1, 0], vec![1, 1, 1]]);
|
|
|
|
|
|
|
|
|
|
|
|
let expected_up = base.clone();
|
|
|
|
let expected_up = base.matrix.clone();
|
|
|
|
let actual_up = base.rotated(Orientation::Up);
|
|
|
|
let actual_up = base.rotated_matrix(Orientation::Up);
|
|
|
|
|
|
|
|
|
|
|
|
let expected_down = ShapeLayout(vec![vec![1, 1, 1], vec![0, 1, 0]]);
|
|
|
|
let expected_down = ShapeLayout::new(vec![vec![1, 1, 1], vec![0, 1, 0]]).matrix;
|
|
|
|
let actual_down = base.rotated(Orientation::Down);
|
|
|
|
let actual_down = base.rotated_matrix(Orientation::Down);
|
|
|
|
|
|
|
|
|
|
|
|
let expected_right = ShapeLayout(vec![vec![1, 0], vec![1, 1], vec![1, 0]]);
|
|
|
|
let expected_right = ShapeLayout::new(vec![vec![1, 0], vec![1, 1], vec![1, 0]]).matrix;
|
|
|
|
let actual_right = base.rotated(Orientation::Right);
|
|
|
|
let actual_right = base.rotated_matrix(Orientation::Right);
|
|
|
|
|
|
|
|
|
|
|
|
let expected_left = ShapeLayout(vec![vec![0, 1], vec![1, 1], vec![0, 1]]);
|
|
|
|
let expected_left = ShapeLayout::new(vec![vec![0, 1], vec![1, 1], vec![0, 1]]).matrix;
|
|
|
|
let actual_left = base.rotated(Orientation::Left);
|
|
|
|
let actual_left = base.rotated_matrix(Orientation::Left);
|
|
|
|
|
|
|
|
|
|
|
|
debug_assert_eq!(expected_up, actual_up);
|
|
|
|
debug_assert_eq!(expected_up, actual_up);
|
|
|
|
debug_assert_eq!(expected_down, actual_down);
|
|
|
|
debug_assert_eq!(expected_down, actual_down);
|
|
|
|
@ -83,11 +96,10 @@ fn test_rotation_02() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn test_rotation_03() {
|
|
|
|
fn test_rotation_03() {
|
|
|
|
let base = ShapeLayout(vec![vec![0, 1, 0], vec![1, 1, 1]]);
|
|
|
|
let base = ShapeLayout::new(vec![vec![0, 1, 0], vec![1, 1, 1]]);
|
|
|
|
|
|
|
|
|
|
|
|
let actual_right = base.rotated(Orientation::Right);
|
|
|
|
let actual_right = base.rotated_matrix(Orientation::Right);
|
|
|
|
let expected_right = ShapeLayout(vec![vec![1, 0], vec![1, 1], vec![1, 0]]);
|
|
|
|
let expected_right = ShapeLayout::new(vec![vec![1, 0], vec![1, 1], vec![1, 0]]).matrix;
|
|
|
|
|
|
|
|
|
|
|
|
debug_assert_eq!(expected_right, actual_right);
|
|
|
|
debug_assert_eq!(expected_right, actual_right);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|