-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTownTest.java
59 lines (50 loc) · 1.72 KB
/
TownTest.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package isp;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.io.FileNotFoundException;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author Ethan Gruening
* Tests the Town functions with JUnit 5
*/
public class TownTest {
@Test
@DisplayName("Check for correct town width return")
void getWidth() {
Town p = new Town(5,4);
assertEquals(4, p.getWidth(), "Expected Width 4, Returned: " +p.getWidth());
}
@Test
@DisplayName("Check for correct town length return")
void getLength() {
Town p = new Town(5,4);
assertEquals(5, p.getLength(),"Expected Length 4, Returned: " +p.getLength());
}
@Test
@DisplayName("Tests the randomInit functionality")
void randomInit() {
Town p = new Town(5, 4);
p.randomInit(25);
boolean tester = true;
//checks if all spaces are filled with an object
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 4; j++) {
if(p.grid[i][j] == null){
tester = false;
}
}
}
assertEquals(true, tester, "Not all values in the town's grid was filled with a TownCell");
}
@Test
@DisplayName("Checks the proper string is outputted")
void ToString() throws FileNotFoundException {
Town p = new Town("tester2.txt");
String test = "S E R E R\n" +
"E C R S O\n" +
"C E O S S\n" +
"C S R O R\n" +
"S C O O R";
assertEquals(test, p.toString(),"Expect town's string: \n" + test + "\nActual: \n " + p.toString());
}
}