-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLevelTest
More file actions
172 lines (146 loc) · 5.04 KB
/
LevelTest
File metadata and controls
172 lines (146 loc) · 5.04 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
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
package com.cs2114.dungeonescape;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
// -------------------------------------------------------------------------
/**
* Test the Level Class
*
* @author Joe Bruzek, Yash Pant, Marcus Stewart
* @version Dec 5, 2013
*/
public class LevelTest
{
private Level level;
/**
* set up a level and put the starting cell right in the center
*/
@Before
public void setUp()
{
level =
new Level("33333333333333333333311111131111111131113111111111111"
+ "11131133111111111111111311331111111111111333113311111"
+ "11111111111113311111111111111111133111111111111111111"
+ "33111111111111111111333311111111111111113311111111111"
+ "11111123311111111111111111233111133333111111112331111"
+ "11111111131112331111111111111311123311111111111113111"
+ "23311111111111113111233111111131111131112331111111311"
+ "11132222333333333333333333333001099199001");
level.setStart(new Location(4, 4));
}
/**
* test the resetPath method implicitly test the setCurrentLocation method
*/
@Test
public void testResetPath()
{
level.east();
level.west();
assertEquals(3, level.getPath().size());
level.resetPath();
assertEquals(1, level.getPath().size());
}
/**
* test the getCurrentLocation method
*/
@Test
public void testGetCurrentLocation()
{
assertEquals(new Location(4, 4), level.getCurrentLocation());
}
/**
* test the setStart and setGoal methods implicitly test the getStart and
* getGoal methods
*/
@Test
public void testSetStartGoal()
{
Location start = new Location(1, 1);
level.setStart(start);
assertEquals(start, level.getStart());
Location goal = new Location(2, 2);
level.setGoal(goal);
assertEquals(goal, level.getGoal());
}
/**
* test the restart method
*/
@Test
public void testRestart()
{
level.restart("3333333333333333333331111113111111113111311111111111"
+ "11113113311111111111111131133111111111111133311331111"
+ "11111111111111331111111111111111113311111111111111111"
+ "13311111111111111111133331111111111111111331111111111"
+ "11111112331111111111111111123311113333311111111233111"
+ "11111111113111233111111111111131112331111111111111311"
+ "12331111111111111311123311111113111113111233111111131"
+ "111132222333333333333333333333001099199001");
assertEquals(Cell.WALL, level.getCell(new Location(0, 0)));
}
/**
* Test the east method the current cell should be the farthest east clear
* cell the top cell in the path should be the current cell the second cell
* in the path should be the starting position
*/
@Test
public void testEast()
{
level.east();
Location test = new Location(13, 4);
Location test2 = new Location(4, 4);
assertEquals(test, level.getCurrentLocation());
level.getPath().tail();
assertEquals(test, level.getPath().previous());
assertEquals(test2, level.getPath().previous());
}
/**
* Test the west method the current cell should be the farthest west clear
* cell the top cell in the path should be the current cell the second cell
* in the path should be the starting position
*/
@Test
public void testWest()
{
level.west();
Location test = new Location(1, 4);
Location test2 = new Location(4, 4);
assertEquals(test, level.getCurrentLocation());
level.getPath().tail();
assertEquals(test, level.getPath().previous());
assertEquals(test2, level.getPath().previous());
}
/**
* Test the north method the current cell should be the farthest north clear
* cell the top cell in the path should be the current cell the second cell
* in the path should be the starting position
*/
@Test
public void testNorth()
{
level.north();
Location test = new Location(4, 1);
Location test2 = new Location(4, 4);
assertEquals(test, level.getCurrentLocation());
level.getPath().tail();
assertEquals(test, level.getPath().previous());
assertEquals(test2, level.getPath().previous());
}
/**
* Test the south method the current cell should be the farthest south clear
* cell the top cell in the path should be the current cell the second cell
* in the path should be the starting position
*/
@Test
public void testSouth()
{
level.south();
Location test = new Location(4, 18);
Location test2 = new Location(4, 4);
assertEquals(test, level.getCurrentLocation());
level.getPath().tail();
assertEquals(test, level.getPath().previous());
assertEquals(test2, level.getPath().previous());
}
}