def test_right_up(self): """Test that the grid is traversed right-up diagonally from the position.""" depth = 4 expected = [26, 75, 36, 56] grid = Grid() position = (8, 6) actual = grid.right_up(position, depth) self.assertListEqual(expected, actual)
def test_left_down(self): """Test that the grid is traversed left-down diagonally from the position.""" depth = 4 expected = [26, 20, 99, 0] grid = Grid() position = (8, 6) actual = grid.left_down(position, depth) self.assertListEqual(expected, actual)
def test_up(self): """Test that the grid is traversed upwards from the position.""" depth = 4 expected = [26, 44, 41, 69] grid = Grid() position = (8, 6) actual = grid.up(position, depth) self.assertListEqual(expected, actual)
def test_right_down(self): """Test that the grid is traversed right-down diagonally from the position.""" depth = 4 expected = [26, 63, 78, 14] grid = Grid() position = (8, 6) actual = grid.right_down(position, depth) self.assertListEqual(expected, actual)
def test_right(self): """Test that the grid is traversed to the right from the position.""" depth = 4 expected = [26, 38, 40, 67] grid = Grid() position = (8, 6) actual = grid.right(position, depth) self.assertListEqual(expected, actual)
def test_left(self): """Test that the grid is traversed to the left from the position.""" depth = 4 expected = [26, 10, 67, 23] grid = Grid() position = (8, 6) actual = grid.left(position, depth) self.assertListEqual(expected, actual)
def test_down(self): """Test that the grid is traversed downwards from the position.""" depth = 4 expected = [26, 95, 97, 20] grid = Grid() position = (8, 6) actual = grid.down(position, depth) self.assertListEqual(expected, actual)
def test_right_up_exceeding_depth(self): """Test that diagonal right-up does not raise an IndexError.""" depth = 4 expected = [] grid = Grid() parameterized_data = [(19, 0), (18, 1), (17, 2)] for position in parameterized_data: with self.subTest(i=position): actual = grid.right_up(position, depth) self.assertListEqual(expected, actual)
def test_left_down_exceeding_depth(self): """Test that diagonal left-down does not raise an IndexError.""" depth = 4 expected = [] grid = Grid() parameterized_data = [(0, 19), (1, 18), (2, 17)] for position in parameterized_data: with self.subTest(i=position): actual = grid.left_down(position, depth) self.assertListEqual(expected, actual)
def test_up_exceeding_depth(self): """Test that up does not raise an IndexError when the depth exceeds the grid.""" depth = 4 expected = [] grid = Grid() parameterized_data = [(0, 0), (0, 1), (0, 2)] for position in parameterized_data: with self.subTest(i=position): actual = grid.up(position, depth) self.assertListEqual(expected, actual)