@@ -11,15 +11,9 @@ class RatInAMazeTest {
1111
1212 @ Test
1313 void testMultiplePathsExist () {
14- // This maze has exactly 2 paths: DDRDRR and DRDDRR
15- int [][] maze = {
16- {1 , 0 , 0 , 0 },
17- {1 , 1 , 0 , 1 },
18- {0 , 1 , 0 , 0 },
19- {0 , 1 , 1 , 1 }
20- };
14+ int [][] maze = {{1 , 0 , 0 , 0 }, {1 , 1 , 0 , 1 }, {0 , 1 , 0 , 0 }, {0 , 1 , 1 , 1 }};
15+
2116 List <String > paths = RatInAMaze .findPaths (maze );
22- // Verify at least one valid path exists and all paths are valid
2317 assertTrue (paths .size () >= 1 );
2418 for (String path : paths ) {
2519 assertTrue (path .chars ().allMatch (c -> "DLRU" .indexOf (c ) >= 0 ));
@@ -28,43 +22,29 @@ void testMultiplePathsExist() {
2822
2923 @ Test
3024 void testSinglePath () {
31- int [][] maze = {
32- {1 , 0 , 0 },
33- {1 , 1 , 0 },
34- {0 , 1 , 1 }
35- };
25+ int [][] maze = {{1 , 0 , 0 }, {1 , 1 , 0 }, {0 , 1 , 1 }};
3626 List <String > paths = RatInAMaze .findPaths (maze );
3727 assertEquals (1 , paths .size ());
3828 assertEquals ("DRDR" , paths .get (0 ));
3929 }
4030
4131 @ Test
4232 void testNoPathExists () {
43- int [][] maze = {
44- {1 , 0 , 0 },
45- {0 , 0 , 0 },
46- {0 , 0 , 1 }
47- };
33+ int [][] maze = {{1 , 0 , 0 }, {0 , 0 , 0 }, {0 , 0 , 1 }};
4834 List <String > paths = RatInAMaze .findPaths (maze );
4935 assertTrue (paths .isEmpty ());
5036 }
5137
5238 @ Test
5339 void testSourceBlocked () {
54- int [][] maze = {
55- {0 , 1 },
56- {1 , 1 }
57- };
40+ int [][] maze = {{0 , 1 }, {1 , 1 }};
5841 List <String > paths = RatInAMaze .findPaths (maze );
5942 assertTrue (paths .isEmpty ());
6043 }
6144
6245 @ Test
6346 void testDestinationBlocked () {
64- int [][] maze = {
65- {1 , 1 },
66- {1 , 0 }
67- };
47+ int [][] maze = {{1 , 1 }, {1 , 0 }};
6848 List <String > paths = RatInAMaze .findPaths (maze );
6949 assertTrue (paths .isEmpty ());
7050 }
@@ -91,7 +71,7 @@ void testNullMazeThrowsException() {
9171
9272 @ Test
9373 void testEmptyMazeThrowsException () {
94- assertThrows (IllegalArgumentException .class , () -> RatInAMaze .findPaths (new int [][]{}));
74+ assertThrows (IllegalArgumentException .class , () -> RatInAMaze .findPaths (new int [][] {}));
9575 }
9676
9777 @ Test
@@ -102,28 +82,19 @@ void testNonSquareMazeThrowsException() {
10282
10383 @ Test
10484 void testAllCellsOpen () {
105- int [][] maze = {
106- {1 , 1 , 1 },
107- {1 , 1 , 1 },
108- {1 , 1 , 1 }
109- };
85+ int [][] maze = {{1 , 1 , 1 }, {1 , 1 , 1 }, {1 , 1 , 1 }};
11086 List <String > paths = RatInAMaze .findPaths (maze );
11187 assertTrue (paths .size () > 1 );
11288 }
11389
11490 @ Test
11591 void testLargerMazeWithPath () {
116- int [][] maze = {
117- {1 , 1 , 1 , 1 },
118- {0 , 1 , 0 , 1 },
119- {0 , 1 , 0 , 1 },
120- {0 , 1 , 1 , 1 }
121- };
92+ int [][] maze = {{1 , 1 , 1 , 1 }, {0 , 1 , 0 , 1 }, {0 , 1 , 0 , 1 }, {0 , 1 , 1 , 1 }};
12293 List <String > paths = RatInAMaze .findPaths (maze );
12394 assertTrue (paths .size () >= 1 );
12495 for (String path : paths ) {
125- assertTrue (path .chars ().allMatch (c -> "DLRU" .indexOf (c ) >= 0 ),
126- "Path contains invalid characters: " + path );
96+ assertTrue (path .chars ().allMatch (c -> "DLRU" .indexOf (c ) >= 0 ), "Path contains invalid characters: " + path );
12797 }
98+
12899 }
129- }
100+ }
0 commit comments