X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=naja%2Ftests%2Ftest_player.py;h=07583b3bf11a312bdefed1c267f623b069b42c18;hb=25495fec3f11a25cdd632a19a352a10cee105d02;hp=d45c09eadcdad3957862611d5f337b41919c4f56;hpb=aac1783aa9c84031bb37d74616ee72a7b32ebeac;p=naja.git diff --git a/naja/tests/test_player.py b/naja/tests/test_player.py index d45c09e..07583b3 100644 --- a/naja/tests/test_player.py +++ b/naja/tests/test_player.py @@ -1,6 +1,6 @@ from unittest import TestCase -from naja.constants import BITS +from naja.constants import BITS, MOVES from naja.player import PlayerBits, Player @@ -85,6 +85,22 @@ class TestPlayerBits(TestCase): bits.toggle_bits([BITS.NORTH, BITS.BLUE, BITS.MSB]) self.assertEqual(bits._bits, 0x92) + def test_shift_bits_left(self): + bits = PlayerBits(0x03) + self.assertEqual(bits._bits, 0x03) + bits.shift_bits_left(1) + self.assertEqual(bits._bits, 0x06) + bits.shift_bits_left(6) + self.assertEqual(bits._bits, 0x81) + + def test_shift_bits_right(self): + bits = PlayerBits(0x06) + self.assertEqual(bits._bits, 0x06) + bits.shift_bits_right(1) + self.assertEqual(bits._bits, 0x03) + bits.shift_bits_right(1) + self.assertEqual(bits._bits, 0x81) + class TestPlayer(TestCase): def test_new_player(self): @@ -130,17 +146,19 @@ class TestPlayer(TestCase): def test_legal_moves_castle(self): player = Player(0x0f, (1, 3), MOVES.CASTLE) - self.assertEqual(player.legal_moves(), [(0, 3), (1, 0), (1, 1), (1, 2), - (1, 3), (1, 4), (2, 3), (3, 3), (4, 3)]) + self.assertEqual(player.legal_moves(), [ + (0, 3), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, 3), (3, 3), + (4, 3)]) def test_legal_moves_bishop(self): player = Player(0x0f, (1, 3), MOVES.BISHOP) - self.assertEqual(player.legal_moves(), [(0, 2), (0, 4), (1, 3), (2, 2), - (2, 4), (3, 1), (3, 4), (4, 0)]) + self.assertEqual(player.legal_moves(), [ + (0, 2), (0, 4), (1, 3), (2, 2), (2, 4), (3, 1), (4, 0)]) def test_legal_moves_knight(self): player = Player(0x0f, (1, 3), MOVES.KNIGHT) - self.assertEqual(player.legal_moves(), [(0, 1), (2, 1), (3, 2), (3, 4)]) + self.assertEqual(player.legal_moves(), [ + (0, 1), (1, 3), (2, 1), (3, 2), (3, 4)]) def test_set_position(self): player = Player(0x0f, (3, 3), MOVES.BISHOP)