MCPcopy Create free account
hub / github.com/asweigart/PythonStdioGames / test_isWinner

Function test_isWinner

tests/test_fourinarow.py:6–46  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4from gamesbyexample import fourinarow
5
6def test_isWinner():
7 for x in range(fourinarow.BOARD_WIDTH):
8 for y in range(fourinarow.BOARD_HEIGHT):
9 if y < fourinarow.BOARD_HEIGHT - 3:
10 b = fourinarow.getNewBoard()
11 b[(x, y)] = 'X'
12 b[(x, y+1)] = 'X'
13 b[(x, y+2)] = 'X'
14 b[(x, y+3)] = 'X'
15 fourinarow.displayBoard(b)
16 #input()
17 assert fourinarow.isWinner('X', b)
18
19 if x < fourinarow.BOARD_WIDTH - 3:
20 b = fourinarow.getNewBoard()
21 b[(x, y)] = 'X'
22 b[(x+1, y)] = 'X'
23 b[(x+2, y)] = 'X'
24 b[(x+3, y)] = 'X'
25 fourinarow.displayBoard(b)
26 #input()
27 assert fourinarow.isWinner('X', b)
28
29 if (x < fourinarow.BOARD_WIDTH - 3) and (y < fourinarow.BOARD_HEIGHT - 3):
30 b = fourinarow.getNewBoard()
31 b[(x, y)] = 'X'
32 b[(x+1, y+1)] = 'X'
33 b[(x+2, y+2)] = 'X'
34 b[(x+3, y+3)] = 'X'
35 fourinarow.displayBoard(b)
36 #input()
37 assert fourinarow.isWinner('X', b)
38
39 b = fourinarow.getNewBoard()
40 b[(x, y+3)] = 'X'
41 b[(x+1, y+2)] = 'X'
42 b[(x+2, y+1)] = 'X'
43 b[(x+3, y)] = 'X'
44 fourinarow.displayBoard(b)
45 #input()
46 assert fourinarow.isWinner('X', b)
47
48def test_isFull():
49 b = fourinarow.getNewBoard()

Callers

nothing calls this directly

Calls 1

isWinnerMethod · 0.80

Tested by

no test coverage detected