-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_packman.py
78 lines (61 loc) · 2.02 KB
/
test_packman.py
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
from pacman import PacMan
# TODO Test for pyopengl function !!!!
class TestPacMan:
def setup_method(self):
self.pacman = PacMan(1, 1)
def test_pacman_init__1(self):
""""""
assert self.pacman.pos_x == 1
def test_pacman_init__2(self):
""""""
assert self.pacman.pos_z == 1
def test_pacman_init__3(self):
""""""
assert self.pacman.direction == ""
def test_pacman_init__4(self):
""""""
assert self.pacman.next_direction == ""
def test_pacman_init__5(self):
"""PacMan step must be able to be mulitplied to 1"""
avaiable_step = (1, 0.5, 0.25, 0.2, 0.125, 0.1, 0.0625, 0.05)
assert self.pacman.step in avaiable_step
def test_move1(self):
""""""
self.pacman.direction = 'N'
self.pacman.move()
assert self.pacman.rotate == 0
def test_move2(self):
""""""
pos, self.pacman.direction = self.pacman.pos_z, "N"
self.pacman.move()
assert self.pacman.pos_z == pos - self.pacman.step
def test_move3(self):
""""""
self.pacman.direction = 'S'
self.pacman.move()
assert self.pacman.rotate == 180
def test_move4(self):
""""""
pos, self.pacman.direction = self.pacman.pos_z, "S"
self.pacman.move()
assert self.pacman.pos_z == pos + self.pacman.step
def test_move5(self):
""""""
self.pacman.direction = 'W'
self.pacman.move()
assert self.pacman.rotate == 90
def test_move6(self):
""""""
pos, self.pacman.direction = self.pacman.pos_x, "W"
self.pacman.move()
assert self.pacman.pos_x == pos - self.pacman.step
def test_move7(self):
""""""
self.pacman.direction = 'E'
self.pacman.move()
assert self.pacman.rotate == 270
def test_move8(self):
""""""
pos, self.pacman.direction = self.pacman.pos_x, "E"
self.pacman.move()
assert self.pacman.pos_x == pos + self.pacman.step