-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathMatrixRotationTest.java
70 lines (49 loc) · 1.51 KB
/
MatrixRotationTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package by.andd3dfx.common;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class MatrixRotationTest {
private final int[][] EXPECTED_MATRIX = new int[][]{
{3, 4, 5, 6},
{2, 3, 4, 7},
{1, 2, 1, 8},
{12, 11, 10, 9}
};
@Test
public void rotate() {
var matrix = buildMatrix();
MatrixRotation.rotate(matrix, 2);
assertThat(matrix).isEqualTo(EXPECTED_MATRIX);
}
@Test
public void rotateForBigR() {
var matrix = buildMatrix();
MatrixRotation.rotate(matrix, 14);
assertThat(matrix).isEqualTo(EXPECTED_MATRIX);
}
@Test
public void rotateWhenNoRotation() {
var matrix = buildMatrix();
MatrixRotation.rotate(matrix, 0);
assertThat(matrix).isEqualTo(buildMatrix());
}
@Test
public void rotateWhenNoRotation2() {
var matrix = buildMatrix();
MatrixRotation.rotate(matrix, 12);
assertThat(matrix).isEqualTo(buildMatrix());
}
@Test
public void rotateForNegativeR() {
var matrix = buildMatrix();
MatrixRotation.rotate(matrix, -10);
assertThat(matrix).isEqualTo(EXPECTED_MATRIX);
}
private static int[][] buildMatrix() {
return new int[][]{
{1, 2, 3, 4},
{12, 1, 2, 5},
{11, 4, 3, 6},
{10, 9, 8, 7}
};
}
}