def test_goUp_no_move_possible_means_nothing_changed(self): grid = [[0 for i in range(4)] for j in range(4)] grid[0] = [2, 32, 512, 8] grid[1] = [4, 64, 1024, 16] grid[2] = [8, 128, 2, 32] grid[3] = [16, 256, 4, 16] result = goUp(grid) self.assertEqual(result, grid)
def test_goUp_merging_of_equal_numbers(self): grid = [[0 for i in range(4)] for j in range(4)] grid[0] = [0, 4, 0, 0] grid[1] = [2, 0, 0, 16] grid[2] = [0, 0, 8, 0] grid[3] = [2, 4, 8, 16] result = goUp(grid) self.assertEqual( result, [[4, 8, 16, 32], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]])
def test_goUp_move_to_top(self): grid = [[0 for i in range(4)] for j in range(4)] grid[0] = [0, 0, 0, 0] grid[1] = [0, 0, 0, 0] grid[2] = [0, 0, 0, 0] grid[3] = [2, 4, 8, 16] result = goUp(grid) self.assertEqual( result, [[2, 4, 8, 16], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]])
def test_goUp_grid3(self): result = goUp(grid3) self.assertEqual( result, [[512, 4, 2, 8], [0, 16, 8, 512], [0, 8, 4, 0], [0, 0, 512, 0]])
def test_goUp_grid2(self): result = goUp(grid2) self.assertEqual( result, [[2, 2, 8, 8], [4, 32, 32, 4], [16, 0, 0, 16], [32, 0, 0, 32]])
def test_goUp_grid1(self): result = goUp(grid1) self.assertEqual( result, [[2, 2, 8, 2], [4, 16, 32, 4], [2, 64, 64, 0], [1024, 1024, 0, 0]])