-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMazeGeneratorJUnit.java
More file actions
45 lines (35 loc) · 1.15 KB
/
MazeGeneratorJUnit.java
File metadata and controls
45 lines (35 loc) · 1.15 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
package maze;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.util.Scanner;
class MazeGeneratorJUnit {
@Test
void test() throws IOException {
// Ask for the size of the maze
Scanner scan = new Scanner(System.in);
int size = 0;
do {
System.out.print("Input the size for the maze: ");
while (!scan.hasNextInt()) {
// Repeat message when bad input
System.out.println("Needs a valid integer for maze size (3 or Higher)");
System.out.print("Input the size for the maze: ");
scan.next();
}
size = scan.nextInt();
} while (size <= 2);
scan.close();
MazeGenerator maze1 = new MazeGenerator(size);
MazeGenerator maze2 = new MazeGenerator(size);
// Shows different unique random maze for same size
assertNotEquals(maze1, maze2);
// Check for the total number of visited cells. This must be equal to total
// cells
assertEquals(maze1.visitedCells(size), maze2.visitedCells(size));
System.out.println();
System.out.println("======================");
System.out.println("Program Completed!");
System.out.println("======================");
}
}