-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_person.py
78 lines (65 loc) · 2.38 KB
/
test_person.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
__author__ = 'raghuram'
import board
class Test_person:
def test_movement(self):
board1 = board.Board(None,0)
prevX, prevY = board1.plr[0].getPosition()
board1.key_pressed(1)
curX, curY = board1.plr[0].getPosition()
assert curY == prevY
assert curX == prevX + board1.PLAYER_SPEED
def test_right_collision(self):
board1 = board.Board(None,0)
for i in range(300):
board1.key_pressed(1)
curX, curY = board1.plr[0].getPosition()
assert curX <= 1700
def test_left_collision(self):
board1 = board.Board(None,0)
for i in range(300):
board1.key_pressed(1)
for i in range(300):
board1.key_pressed(2)
curX, curY = board1.plr[0].getPosition()
assert curX >= 0
def test_ladder_climb(self):
board1 = board.Board(None,0)
curX, curY = board1.plr[0].getPosition()
board1.plr[0].setPosition((800, curY))
board1.key_pressed(3)
newX, newY = board1.plr[0].getPosition()
assert newY < curY
def test_jump(self):
board1 = board.Board(None, 0)
curX, curY = board1.plr[0].getPosition()
jumpstate = 1
jumpspeed = 10
for i in range(100):
if jumpstate == 1:
if board1.playerjump(jumpspeed) == 1:
jumpstate = 2
jumpspeed = 0
else:
jumpspeed -= 2
if jumpstate == 2:
if board1.playerjumpdown(jumpspeed) == 1:
jumpstate = 0
jumpspeed = 10
else:
jumpspeed += 2
newX, newY = board1.plr[0].getPosition()
assert newY <= curY and newY >= curY - board1.JUMP_LIMIT
def test_coin_collect(self):
board1 = board.Board(None, 0)
curScore = board1.plr[0].getScore()
coin_posX, coin_posY = board1.coins[0].getPosition()
board1.plr[0].setPosition((coin_posX,coin_posY))
collectCoin = board1.getCoinCollisions()
assert collectCoin == 1
def test_midair_fall(self):
board1 = board.Board(None, 0)
curX, curY = (750, 75) #mid air random getPosition
board1.plr[0].setPosition((curX,curY))
board1.checkMidAir()
newX, newY = board1.plr[0].getPosition()
assert newY <= curY