Esempio n. 1
0
 def testNextToTwo(self):
     cells = game.create_cells(game.ROWS, game.COLUMNS)
     cells[0][1] = True
     cells[1][0] = True
     self.assertEqual(False, game.should_live(0, 0, cells), "Should stay dead")
     cells[0][0] = True
     self.assertEqual(True, game.should_live(0, 0, cells), "Should stay alive")
Esempio n. 2
0
 def testNextToMoreThanThree(self):
     cells = game.create_cells(game.ROWS, game.COLUMNS)
     cells[0][0] = True
     cells[0][1] = True
     cells[0][2] = True
     cells[1][0] = True
     self.assertEqual(False, game.should_live(1, 1, cells), "Should stay dead")
     cells[0][0] = True
     self.assertEqual(False, game.should_live(1, 1, cells), "Should die")
Esempio n. 3
0
 def testCellIsolated(self):
     cells = game.create_cells(game.ROWS, game.COLUMNS)
     self.assertEqual(False, game.should_live(0, 0, cells), "Should stay dead")
     cells[0][0] = True
     self.assertEqual(False, game.should_live(0, 0, cells), "Should die")
Esempio n. 4
0
 def testOnRightLowerCornerSurrounded(self):
     cells = game.create_cells(game.ROWS, game.COLUMNS)
     for row in range(game.ROWS - 2, game.ROWS):
         for col in range(game.ROWS - 2, game.ROWS):
             cells[row][col] = True
     self.assertEqual(3, game.get_number_of_neighbors(game.ROWS - 1, game.COLUMNS - 1, cells), "Should be 3")
Esempio n. 5
0
 def testOnRightLowerCornerIsolated(self):
     cells = game.create_cells(game.ROWS, game.COLUMNS)
     self.assertEqual(0, game.get_number_of_neighbors(game.ROWS - 1, game.COLUMNS - 1, cells), "Should be 0")
Esempio n. 6
0
 def testNoRowsNColumns(self):
     self.assertListEqual([], game.create_cells(0, 0), "Should be empty list")
     self.assertListEqual([], game.create_cells(0, 1), "Should be empty list")
     self.assertListEqual([], game.create_cells(0, 2), "Should be empty list")
Esempio n. 7
0
 def testOnCenterSurrounded(self):
     cells = game.create_cells(game.ROWS, game.COLUMNS)
     for row in range(3, 6):
         for col in range(3, 6):
             cells[row][col] = True
     self.assertEqual(8, game.get_number_of_neighbors(4, 4, cells), "Should be 8")
Esempio n. 8
0
 def testOneCenterIsolated(self):
     cells = game.create_cells(game.ROWS, game.COLUMNS)
     self.assertEqual(0, game.get_number_of_neighbors(4, 4, cells), "Should be 0")
Esempio n. 9
0
 def testNot0RowsNot0Columns(self):
     self.assertListEqual([[False]], game.create_cells(1, 1), "Should be list of a list with one element")
     self.assertListEqual([[False, False], [False, False]], game.create_cells(2, 2),
                          "Should be list of two lists of two elements each")
Esempio n. 10
0
 def testNot0Rows0Columns(self):
     self.assertListEqual([[]], game.create_cells(1, 0), "Should be list of one empty list")
     self.assertListEqual([[], []], game.create_cells(2, 0), "Should be list of two empty list")