- Notifications
You must be signed in to change notification settings - Fork 19.9k
/
Copy pathTestPrintMatrixInSpiralOrder.java
26 lines (22 loc) · 1011 Bytes
/
TestPrintMatrixInSpiralOrder.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
packagecom.thealgorithms.matrix;
importstaticorg.junit.jupiter.api.Assertions.assertIterableEquals;
importjava.util.List;
importorg.junit.jupiter.api.Test;
publicclassTestPrintMatrixInSpiralOrder {
@Test
publicvoidtestOne() {
int[][] matrix = {{3, 4, 5, 6, 7}, {8, 9, 10, 11, 12}, {14, 15, 16, 17, 18}, {23, 24, 25, 26, 27}, {30, 31, 32, 33, 34}};
varprintClass = newPrintAMatrixInSpiralOrder();
List<Integer> res = printClass.print(matrix, matrix.length, matrix[0].length);
List<Integer> list = List.of(3, 4, 5, 6, 7, 12, 18, 27, 34, 33, 32, 31, 30, 23, 14, 8, 9, 10, 11, 17, 26, 25, 24, 15, 16);
assertIterableEquals(res, list);
}
@Test
publicvoidtestTwo() {
int[][] matrix = {{2, 2}};
varprintClass = newPrintAMatrixInSpiralOrder();
List<Integer> res = printClass.print(matrix, matrix.length, matrix[0].length);
List<Integer> list = List.of(2, 2);
assertIterableEquals(res, list);
}
}