Example #1
0
    def test(self):
        twenty_forty_eight = TwentyFortyEight(6, 4)
        empty_grid = twenty_forty_eight.generate_empty_grid()
        twenty_forty_eight.grid = empty_grid
        twenty_forty_eight.new_tile()
        self.assertEquals(tiles_greater_zero(twenty_forty_eight._grid), 1)
        self.assertEquals(sum_of_tiles(twenty_forty_eight._grid) > 0, True)

        twenty_forty_eight = TwentyFortyEight()
        empty_grid = twenty_forty_eight.generate_empty_grid()
        twenty_forty_eight.grid = empty_grid
        twenty_forty_eight.new_tile()
        [twenty_forty_eight.new_tile() for dummy_num in range(9)]
        self.assertEquals(tiles_greater_zero(twenty_forty_eight._grid), 10)
        self.assertEquals(sum_of_tiles(twenty_forty_eight._grid) > 0, True)
Example #2
0
    def test(self):
        twenty_forty_eight = TwentyFortyEight()
        empty_grid = twenty_forty_eight.generate_empty_grid()
        twenty_forty_eight.grid = empty_grid
        twenty_forty_eight.set_tile(0, 2, 2)

        self.assertEqual(twenty_forty_eight.check_tile_is_empty(0, 2), False)
        self.assertEqual(twenty_forty_eight.check_tile_is_empty(0, 0), True)
Example #3
0
 def test(self):
     twenty_forty_eight = TwentyFortyEight(6, 4)
     empty_grid = twenty_forty_eight.generate_empty_grid()
     twenty_forty_eight.grid = empty_grid
     self.assertEqual(
         twenty_forty_eight.__str__(),
         '[[0, 0, 0, 0],\n [0, 0, 0, 0],\n [0, 0, 0, 0],\n [0, 0, 0, 0],\n [0, 0, 0, 0],\n [0, 0, 0, 0]]'
     )
Example #4
0
    def test(self):
        twenty_forty_eight = TwentyFortyEight()
        empty_grid = twenty_forty_eight.generate_empty_grid()
        twenty_forty_eight.grid = empty_grid

        self.assertEqual(
            0 <= twenty_forty_eight.get_random_row_index() <
            twenty_forty_eight.grid_height, True)
        self.assertEqual(
            0 <= twenty_forty_eight.get_random_col_index() <
            twenty_forty_eight.grid_width, True)
Example #5
0
    def test(self):
        twenty_forty_eight = TwentyFortyEight()
        empty_grid = twenty_forty_eight.generate_empty_grid()
        twenty_forty_eight.grid = empty_grid
        twenty_forty_eight.set_tile(0, 2, 2)
        twenty_forty_eight.set_tile(0, 3, 4)
        twenty_forty_eight.set_tile(1, 2, 2)

        [
            self.check_get_empty_tile(twenty_forty_eight)
            for dummy_num in range(5)
        ]
Example #6
0

class StrTwentyFortyEightTest1(unittest.TestCase):
    def test(self):
        twenty_forty_eight = TwentyFortyEight(6, 4)
        empty_grid = twenty_forty_eight.generate_empty_grid()
        twenty_forty_eight.grid = empty_grid
        self.assertEqual(
            twenty_forty_eight.__str__(),
            '[[0, 0, 0, 0],\n [0, 0, 0, 0],\n [0, 0, 0, 0],\n [0, 0, 0, 0],\n [0, 0, 0, 0],\n [0, 0, 0, 0]]'
        )


twenty_forty_eight = TwentyFortyEight(6, 4)
empty_grid = twenty_forty_eight.generate_empty_grid()
twenty_forty_eight.grid = empty_grid


class SelectTileIndexTwentyFortyEightTest1(unittest.TestCase):
    def test(self):
        self.assertIsInstance(twenty_forty_eight.select_tile(), tuple)
        row, col = twenty_forty_eight.select_tile()
        self.assertEquals(0 <= row < 6, True)
        self.assertEquals(0 <= col < 4, True)


class SetTileTwentyFortyEightTest1(unittest.TestCase):
    def test(self):
        twenty_forty_eight.set_tile(0, 2, 2)
        self.assertEqual(twenty_forty_eight._grid[0][2], 2)
        self.assertEqual(twenty_forty_eight.get_tile(0, 2), 2)