This repository has been archived by the owner on Apr 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
test.py
61 lines (48 loc) · 2.12 KB
/
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
50
51
52
53
54
55
56
57
58
59
60
61
import unittest
import fairyfishgui
class TestMove(unittest.TestCase):
def test_coordinate_moves(self):
move = fairyfishgui.Move('e2e4,e4e6')
self.assertEqual(move.from_sq, 'e2')
self.assertEqual(move.to_sq, 'e4')
self.assertEqual(move.to_sq2, 'e6')
move = fairyfishgui.Move('h7h8q')
self.assertEqual(move.from_sq, 'h7')
self.assertEqual(move.to_sq, 'h8')
self.assertEqual(move.to_sq2, None)
move = fairyfishgui.Move('a10b10+')
self.assertEqual(move.from_sq, 'a10')
self.assertEqual(move.to_sq, 'b10')
self.assertEqual(move.to_sq2, None)
def test_drop_moves(self):
move = fairyfishgui.Move('Q@a1')
self.assertEqual(move.from_sq, 'Q@')
self.assertEqual(move.to_sq, 'a1')
self.assertEqual(move.to_sq2, None)
move = fairyfishgui.Move('R@b10')
self.assertEqual(move.from_sq, 'R@')
self.assertEqual(move.to_sq, 'b10')
self.assertEqual(move.to_sq2, None)
move = fairyfishgui.Move('+P@a1')
self.assertEqual(move.from_sq, 'P@')
self.assertEqual(move.to_sq, 'a1')
self.assertEqual(move.to_sq2, None)
def test_move_filtering(self):
move = fairyfishgui.Move('e7e8q')
self.assertTrue(move.contains(['e7', 'e8']))
self.assertTrue(move.contains(['e8', 'e7']))
self.assertFalse(move.contains(['e7', 'e7']))
self.assertFalse(move.contains(['e8', 'e8']))
move = fairyfishgui.Move('+P@a10')
self.assertTrue(move.contains(['P@', 'a10']))
self.assertTrue(move.contains(['P@']))
self.assertFalse(move.contains(['a1'])) # substring
move = fairyfishgui.Move('e2e4,e4e6')
self.assertTrue(move.contains(['e2', 'e4', 'e6']))
self.assertTrue(move.contains(['e4', 'e2', 'e6']))
self.assertTrue(move.contains(['e2', 'e4', 'e4']))
self.assertTrue(move.contains(['e4', 'e2', 'e4', 'e6']))
self.assertFalse(move.contains(['e2', 'e4', 'e2']))
self.assertFalse(move.contains(['e2', 'e4', 'e4', 'e4']))
if __name__ == '__main__':
unittest.main(verbosity=2)