-
Notifications
You must be signed in to change notification settings - Fork 0
/
LivingTest.java
55 lines (47 loc) · 1.15 KB
/
LivingTest.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
import static org.junit.Assert.*;
import java.io.FileNotFoundException;
import org.junit.Test;
import org.junit.Before;
import junit.framework.TestCase;
/**
*
* @author Stephanie Engelhardt
*
*/
public class LivingTest extends TestCase{
World w;
@Before
public void setUp() throws FileNotFoundException{
w=new World("public1.txt");
}
@Test
public void testCensus() {
int[] population=new int[5];
w.grid[0][0].census(population);
assertEquals(population[0], 1);
assertEquals(population[1], 0);
assertEquals(population[2], 2);
assertEquals(population[3], 1);
assertEquals(population[4], 0);
}
@Test
public void testCensus2() {
int[] population=new int[5];
w.grid[2][2].census(population);
assertEquals(population[0], 0);
assertEquals(population[1], 1);
assertEquals(population[2], 1);
assertEquals(population[3], 1);
assertEquals(population[4], 1);
}
@Test
public void testCensus3() {
int[] population=new int[5];
w.grid[1][1].census(population);
assertEquals(population[0], 1);
assertEquals(population[1], 1);
assertEquals(population[2], 4);
assertEquals(population[3], 2);
assertEquals(population[4], 1);
}
}