Skip to content

Commit e44f6c4

Browse files
test: add coverage for all-open maze and larger maze path
1 parent a358335 commit e44f6c4

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

src/test/java/com/thealgorithms/backtracking/RatInAMazeTest.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,31 @@ void testNonSquareMazeThrowsException() {
9999
int[][] maze = {{1, 0, 1}, {1, 1, 1}};
100100
assertThrows(IllegalArgumentException.class, () -> RatInAMaze.findPaths(maze));
101101
}
102+
103+
@Test
104+
void testAllCellsOpen() {
105+
int[][] maze = {
106+
{1, 1, 1},
107+
{1, 1, 1},
108+
{1, 1, 1}
109+
};
110+
List<String> paths = RatInAMaze.findPaths(maze);
111+
assertTrue(paths.size() > 1);
112+
}
113+
114+
@Test
115+
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+
};
122+
List<String> paths = RatInAMaze.findPaths(maze);
123+
assertTrue(paths.size() >= 1);
124+
for (String path : paths) {
125+
assertTrue(path.chars().allMatch(c -> "DLRU".indexOf(c) >= 0),
126+
"Path contains invalid characters: " + path);
127+
}
128+
}
102129
}

0 commit comments

Comments
 (0)