-
Notifications
You must be signed in to change notification settings - Fork 0
/
RabbitTest.java
53 lines (46 loc) · 1.08 KB
/
RabbitTest.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
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 RabbitTest extends TestCase{
public int row, age, column;
public World w;
public Rabbit r;
/*
* Sets up a rabbit in world w with the age of 0. (non-Javadoc)
* It ensures that the constructor works properly.
* @see junit.framework.TestCase#setUp()
*/
@Before
public void setUp() throws FileNotFoundException{
age=0;
row = 1;
column=2;
w= new World("public1.txt");
r= (Rabbit) w.grid[row][column];
}
/*
* Ensures that the State is implemented correctly and that when the grid from
* the current world is called with this rabbits's row and column that the .who()
* method returns rabbit
*/
@Test
public void testWho() {
State who=w.grid[row][column].who();
assertEquals(State.RABBIT, who);
}
/*
* Tests the myAge() method from the Animal class
*/
@Test
public void testAge() {
int age= r.myAge();
assertEquals(0,age);
}
}