-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCaseTest.java
More file actions
54 lines (42 loc) · 1.45 KB
/
Copy pathCaseTest.java
File metadata and controls
54 lines (42 loc) · 1.45 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
46
47
48
49
50
51
52
53
54
import static org.junit.Assert.*;
import org.junit.Test;
public class CaseTest {
@Test
public void testConstructorAndGetters() {
Case c = new Case(1, 1);
assertEquals("Testing constructor and x-axis value getter method", 1, c.getAbscisse());
assertEquals("Testing constructor and y-axis value getter method", 1, c.getOrdonnee());
// illegal co-ordinate for our game grid
c = new Case(-1, 5);
}
@SuppressWarnings("deprecation")
@Test
public void testNeighbours() {
Case c = new Case(1,1);
Case correctNorth = new Case(1,2);
Case correctEast = new Case(2,1);
Case correctWest = new Case(0,1);
Case correctSouth = new Case(1,0);
Case[] voisines = new Case[]{correctNorth,correctEast,correctWest,correctSouth};
assertEquals("Testing north", correctNorth,c.nord());
assertEquals("Testing east", correctEast,c.est());
assertEquals("Testing west", correctWest,c.ouest());
assertEquals("Testing south", correctSouth, c.sud());
assertEquals("Testing neighbours getter", voisines,c.voisines());
}
@Test
public void testEquals() {
Case c = new Case(1,1);
Case d = c;
Case e = new Case(2,2);
assertEquals("Testing equality",c,d);
assertNotEquals("Testing inequality",c,e);
}
@Test
public void testToString() {
Case c = new Case(1,1);
String s = "(1, 1)";
assertEquals("Testing toString",s,c.toString());
assertNotEquals("Testing toString","",c.toString());
}
}