- Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMatrixTest.java
More file actions
Latest commit
81 lines (63 loc) · 2.12 KB
/
Copy pathMatrixTest.java
File metadata and controls
81 lines (63 loc) · 2.12 KB
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
71
72
73
74
75
76
77
78
79
80
81
packagedataStructures.matrix;
importstaticorg.junit.jupiter.api.Assertions.assertEquals;
importstaticorg.junit.jupiter.api.Assertions.assertThrows;
importstaticorg.junit.jupiter.api.Assertions.fail;
importorg.junit.jupiter.api.DisplayName;
importorg.junit.jupiter.api.Test;
publicclassMatrixTest {
@Test
@DisplayName("rotate matrix")
publicvoidtestRotate() {
Matrixa = newMatrix();
int[][] arrayA = newint[][] { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } };
a.set(arrayA);
a.rotate();
Stringexpected = a.toString();
Matrixb = newMatrix();
int[][] arrayB = newint[][] { { 7, 4, 1 }, { 8, 5, 2 }, { 9, 6, 3 } };
b.set(arrayB);
Stringactual = b.toString();
assertEquals(expected, actual, "Rotation matrix should work");
System.out.println("Test - Matrix : rotate() - passed ok");
}
@Test
@DisplayName("transpose matrix")
publicvoidtestTranspose() {
Matrixa = newMatrix();
int[][] arrayA = newint[][] { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } };
a.set(arrayA);
a.transpose();
Stringexpected = a.toString();
Matrixb = newMatrix();
int[][] arrayB = newint[][] { { 1, 4, 7 }, { 2, 5, 8 }, { 3, 6, 9 } };
b.set(arrayB);
Stringactual = b.toString();
assertEquals(expected, actual, "Transpose matrix should work");
System.out.println("Test - Matrix : transpose() - passed ok");
}
@Test
@DisplayName("reflect matrix")
publicvoidtestReflect() {
Matrixa = newMatrix();
int[][] arrayA = newint[][] { { 1, 4, 7 }, { 2, 5, 8 }, { 3, 6, 9 } };
a.set(arrayA);
a.reflect();
Stringexpected = a.toString();
Matrixb = newMatrix();
int[][] arrayB = newint[][] { { 7, 4, 1 }, { 8, 5, 2 }, { 9, 6, 3 } };
b.set(arrayB);
Stringactual = b.toString();
assertEquals(expected, actual, "Reflect matrix should work");
System.out.println("Test - Matrix : reflect() - passed ok");
}
@Test
publicvoidtestSet_IS_NULL() {
int[][] expectedArr = null;
Matrixa = newMatrix();
assertThrows(IllegalArgumentException.class, () -> {
a.set(expectedArr);
fail("Input null matrix");
});
System.out.println("Test - Matrix : added NULL array - passed ok");
}
}