-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTileTest.java
94 lines (77 loc) · 2.83 KB
/
TileTest.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import org.junit.Test;
import java.util.Arrays;
import static org.junit.Assert.*;
public class TileTest {
Tile allTrueTile = new Tile(true, true, true, 1, new Integer[]{0, 1, 2, 2}, 'T');
Tile allFalseTile = new Tile(false, false, false, 2, new Integer[]{2, 1, 0, 1}, 'F');
@Test
public void ctorTrueTileWorks() throws Exception {
assertTrue(allTrueTile.hasDen);
assertTrue(allTrueTile.lakesAreIndependent);
assertTrue(allTrueTile.trailsEnd);
assertTrue(allTrueTile.animalType == 1);
}
@Test
public void ctorFalseTileWorks() throws Exception {
assertFalse(allTrueTile.animalType == 2);
assertFalse(allFalseTile.hasDen);
assertFalse(allFalseTile.lakesAreIndependent);
assertFalse(allFalseTile.trailsEnd);
}
@Test
public void ctorEdgesWorks() throws Exception {
assertArrayEquals(allTrueTile.edgeValues, new Integer[]{0,1,2,2});
assertArrayEquals(allFalseTile.edgeValues, new Integer []{2,1,0,1});
}
@Test
public void ctorTileTypeWorks() throws Exception {
assertEquals(allFalseTile.tileType, 'F');
assertNotEquals(allFalseTile.tileType, 'T');
}
@Test
public void isEqual() throws Exception {
assertFalse(allFalseTile.isEqual(allTrueTile));
assertTrue(allTrueTile.isEqual(allTrueTile));
}
@Test
public void rotateClockwise1() throws Exception {
allTrueTile.rotateClockwise(1);
assertArrayEquals(allTrueTile.edgeValues, new Integer[]{2,0,1,2});
}
@Test
public void rotateClockwise2() throws Exception {
allTrueTile.rotateClockwise(2);
assertArrayEquals(allTrueTile.edgeValues, new Integer[]{2,2,0,1});
}
@Test
public void rotateClockwise3() throws Exception {
allTrueTile.rotateClockwise(3);
assertArrayEquals(allTrueTile.edgeValues, new Integer[]{1,2,2,0});
}
@Test
public void rotateClockwise4() throws Exception {
allTrueTile.rotateClockwise(4);
assertArrayEquals(allTrueTile.edgeValues, new Integer[]{0,1,2,2});
}
@Test
public void rotateClockwise5() throws Exception {
Tile trueCopy = allTrueTile;
allTrueTile.rotateClockwise(5);
trueCopy.rotateClockwise(1);
assertArrayEquals(allTrueTile.edgeValues, trueCopy.edgeValues);
}
@Test
public void rotateAntiClockwise1() throws Exception {
Tile trueCopy = allTrueTile;
allTrueTile.rotateClockwise(-1);
trueCopy.rotateClockwise(3);
assertArrayEquals(allTrueTile.edgeValues, trueCopy.edgeValues);
}
@Test
public void rotateAntiClockwise3() throws Exception {
Tile trueCopy = allTrueTile;
allTrueTile.rotateClockwise(-3);
trueCopy.rotateClockwise(1);
assertArrayEquals(allTrueTile.edgeValues, trueCopy.edgeValues);
}
}