Skip to content

Commit 3447104

Browse files
authored
Add files via upload
1 parent 7a5102c commit 3447104

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.thealgorithms.others;
2+
3+
import java.util.List;
4+
5+
import org.junit.jupiter.api.Test;
6+
import static org.junit.jupiter.api.Assertions.*;
7+
8+
public class TestPrintMatrixInSpiralOrder {
9+
@Test
10+
public void testOne() {
11+
int[][] matrix = {
12+
{ 3, 4, 5, 6, 7 },
13+
{ 8, 9, 10, 11, 12 },
14+
{ 14, 15, 16, 17, 18 },
15+
{ 23, 24, 25, 26, 27 },
16+
{ 30, 31, 32, 33, 34 }
17+
};
18+
var printClass = new PrintAMatrixInSpiralOrder();
19+
List<Integer> res = printClass.print(matrix, matrix.length, matrix[0].length);
20+
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,
21+
24, 15, 16);
22+
assertIterableEquals(res, list);
23+
}
24+
25+
@Test
26+
public void testTwo() {
27+
int[][] matrix = {
28+
{ 2, 2 }
29+
};
30+
var printClass = new PrintAMatrixInSpiralOrder();
31+
List<Integer> res = printClass.print(matrix, matrix.length, matrix[0].length);
32+
List<Integer> list = List.of(2, 2);
33+
assertIterableEquals(res, list);
34+
}
35+
}

0 commit comments

Comments
 (0)