-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTestSnake.java
More file actions
55 lines (36 loc) · 1.17 KB
/
TestSnake.java
File metadata and controls
55 lines (36 loc) · 1.17 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
public class TestSnake extends TestUtils {
static Snake testSnake;
public static void main(String[] args) {
// call testing functions here
// ie
testHead();
testMove();
testTurn();
}
// reset snake env
public static void setup() {
testSnake = new Snake(new Coord(10, 10));
}
// Tests
public static void testHead() {
setup();
// tests that snake initialises with a positions vector by returning head
expect(equal((new Coord(10, 10)), testSnake.head()), "Snake head not at 10, 10");
}
public static void testMove() {
setup();
testSnake.move();
testSnake.move();
testSnake.move();
expect(equal((new Coord(10, 7)), testSnake.head()), "Snake not moving");
}
public static void testTurn() {
setup();
testSnake.right();
expect(equal(1, testSnake.direction()), "Snake not turning right");
testSnake.down();
expect(equal(2, testSnake.direction()), "Snake not turning down");
testSnake.left();
expect(equal(3, testSnake.direction()), "Snake not turning left");
}
}