-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtests.py
65 lines (49 loc) · 2.32 KB
/
tests.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
import unittest
from Point import Point
from Board import Board
class PointTestCase(unittest.TestCase):
def setUp(self):
self.points = [Point(i) for i in range(25)]
def test_coord(self):
self.assertEqual(self.points[0].coord, 'A1')
self.assertEqual(self.points[12].coord, 'C3')
self.assertEqual(self.points[24].coord, 'E5')
def test_index(self):
self.assertEqual(self.points[0].index, 0)
self.assertEqual(self.points[12].index, 12)
def test_get_index(self):
self.assertEqual(Point.get_index('C3'), 12)
self.assertEqual(Point.get_index('E4'), 19)
def test_set_state(self):
self.points[0].set_state('T')
self.assertEqual(self.points[0].state, Point.State.T)
self.assertEqual(self.points[0].get_state(), Point.State.T)
def test_str(self):
self.assertEqual(str(self.points[0]), 'A1')
class BoardTestCase(unittest.TestCase):
def setUp(self):
self.board = Board()
self.board2 = Board('1GG1G/1GGGT/GGGGG/1GTGG/GTGTG t g0 c3 mA3')
self.t_win = Board('G4/GG2T/GG1GG/TG1TG/TGGGG t g0 c5 mC4E4')
self.g_win = Board('1GG1G/1GGGT/1GGGG/GGTGG/GTGTG t g0 c3 mA3')
def test_init(self):
self.assertEqual(self.board.tigerPos, [0, 4, 20, 24])
def test_reset(self):
self.assertEqual(len(self.board.points), 25)
self.assertEqual(self.board.goatsToBePlaced, 20)
self.assertEqual(self.board.deadGoats, 0)
self.assertEqual(self.board.turn, Board.Player.G)
self.assertEqual(self.board.lastMove, "")
def test_get_full_position(self):
self.assertEqual(Board._get_full_position('1GG1G/1GGGT/GGGGG/1GTGG/GTGTG'), list('EGGEGEGGGTGGGGGEGTGGGTGTG'))
self.assertEqual(Board._get_full_position(self.t_win.position.split()[0]), list('GEEEEGGEETGGEGGTGETGTGGGG'))
def test_position(self):
self.assertEqual(self.board2.position, '1GG1G/1GGGT/GGGGG/1GTGG/GTGTG t g0 c3 mA3')
self.assertEqual(self.g_win.position, '1GG1G/1GGGT/1GGGG/GGTGG/GTGTG t g0 c3 mA3')
def test_winner(self):
self.assertEqual(self.t_win.winner, Board.Player.T)
self.assertEqual(self.g_win.winner, Board.Player.G)
self.assertIsNone(self.board.winner)
self.assertIsNone(self.board2.winner)
def test_parse_position(self):
pass