-
Notifications
You must be signed in to change notification settings - Fork 0
/
input_parser_test.py
49 lines (36 loc) · 1.51 KB
/
input_parser_test.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
""" input_parser_test.py """
import unittest
import input_parser
class TestInputParser(unittest.TestCase):
def test_piece_eats(self):
expected = True
for input_move in ['Kxf3','axb2','Rxd2']:
actual = input_parser.piece_eats(input_move)
self.assertEqual(expected, actual)
expected = False
for input_move in ['a2','Bf3','q']:
actual = input_parser.piece_eats(input_move)
self.assertEqual(expected, actual)
def test_parse_pawn_coordinates(self):
expected = [('a','2', None, None),
('b','2', None, None)]
test_cases = ['a2','axb2']
for k in range(len(test_cases)):
input_move = test_cases[k]
actual = input_parser.parse_pawn_coordinates(input_move)
self.assertEqual(expected[k], actual)
def test_parse_main_pieces_coordinates(self):
expected = [('f','2', None, None),
('b','3', None, None),
('f','2', None, '3'),
('g','4', 'a', None),
('h','3', 'c', '3') ,
('f','4', 'd', None),
('h','8', 'a', '1')]
test_cases = ['Bf2','Qxb3', 'B3f2', 'Bag4', 'Rc3h3','Qdxf4', 'Qa1xh8' ]
for k in range(len(test_cases)):
input_move = test_cases[k]
actual = input_parser.parse_main_pieces_coordinates(input_move)
self.assertEqual(expected[k], actual)
if __name__ == '__main__':
unittest.main()