def setUp(self) -> None: o = None block00 = Block.from_int_array([[o, o, o], [1, o, o], [o, o, o]]) block01 = Block.from_int_array([[o, o, o], [0, 1, o], [o, o, o]]) block10 = Block.from_int_array([[1, 0, 1], [1, 1, o], [1, 1, 1]]) block11 = Block.from_int_array([[o, o, o], [1, o, o], [o, 1, o]]) self.test_board = Board([[block00, block01], [block10, block11]])
def test_rotate_block(self): o = None tests = [{ 'rot': Rotation(Position(0, 0), True), 'new': Block.from_int_array([[1, 1, o], [1, o, o], [o, o, o]]) }, { 'rot': Rotation(Position(0, 1), False), 'new': Block.from_int_array([[o, o, o], [o, 1, o], [o, 0, 1]]) }] for test in tests: new_board = self.test_board.rotate_block(test['rot']) self.assertEqual(new_board.get_block(test['rot'].get_block_pos()), test['new'])
def setUp(self) -> None: o = None self.test_block = Block.from_int_array([ [o, o, o], [1, 1, 1], [0, 1, 0], ])
def test_play_marble(self): o = None tests = [{ 'move': Placement(Position(0, 0), Position(0, 0)), 'new': Block.from_int_array([[1, o, o], [1, o, o], [1, 1, o]]), 'colour': 1 }, { 'move': Placement(Position(0, 1), Position(2, 1)), 'new': Block.from_int_array([[o, o, o], [0, 1, o], [1, 0, o]]), 'colour': 0 }] for test in tests: new_board = self.test_board.play_marble(test['move'], test['colour']) self.assertEqual(new_board.get_block(test['move'].get_block_pos()), test['new'])
def test_clockwise_rotate(self): o = None rotated_block = Block.from_int_array([ [0, 1, o], [1, 1, o], [0, 1, o], ]) msg = 'rotate anticlockwise not performing as expected' self.assertEqual(self.test_block.rotate_clockwise(), rotated_block, msg) self.assertEqual( rotated_block.rotate_anticlockwise().rotate_clockwise(), rotated_block)