Exemplo n.º 1
0
 def test2x2SquareFullOfLiveCellsSurviveNewGeneration(self):
     resultBoard = """
                 # # 
                 # # 
             
                 """
     self.board.setCellAlive(0, 0)
     self.board.setCellAlive(1, 0)
     self.board.setCellAlive(1, 1)
     self.board.setCellAlive(0, 1)
     self.assertEquals(Board.newFromStr(resultBoard, self.evManager), self.board)
     self.board.newGeneration()
     self.assertEquals(Board.newFromStr(resultBoard, self.evManager), self.board)
Exemplo n.º 2
0
 def testLiveCellWithFourNeighboursDies(self):
     resultBoard = """
                 . . . . 
                 . . . # 
                 . # . # 
                 . # # # 
               """
     startBoard = """
                 . . . . 
                 . . . # 
                 . # # # 
                 . . # . 
               """
     self.board = Board.newFromStr(startBoard, self.evManager)
     self.board.newGeneration()
     self.assertTrue(Board.newFromStr(resultBoard, self.evManager) == self.board)
Exemplo n.º 3
0
 def testEquals(self):
     strBoard1 = """
                 . .
                 . #
             
                 """
     
     strBoard2 = """
                 . #
                 . #
             
                 """
     board1 = Board.newFromStr(strBoard1, self.evManager)
     board2 = Board.newFromStr(strBoard1, self.evManager)
     self.assertTrue(board1 == board2)
     board3 = Board.newFromStr(strBoard2, self.evManager)
     self.assertFalse(board1 == board3)
Exemplo n.º 4
0
 def testEquals2x2OnGeneration(self):
     strBoard1 = """
                 . #
                 # #
             
                 """
     
     strBoard2 = """
                 # #
                 # #
             
                 """
     
     board1 = Board.newFromStr(strBoard1, self.evManager)
     board1.newGeneration()
     board2 = Board.newFromStr(strBoard2, self.evManager)
     self.assertTrue(board1 == board2)
Exemplo n.º 5
0
 def testShouldBeAbleToDefineBoardWithString(self):
     strBoard = """
                 . .
                 . .
             
                 """
     self.board = Board.newFromStr(strBoard, self.evManager)
     self.assertEquals(4, len(self.board.fields))
Exemplo n.º 6
0
 def testShouldBeAbleToDetermineLiveCellsWithString(self):
     strBoard = """
                 . .
                 . #
             
                 """
     self.board = Board.newFromStr(strBoard, self.evManager)
     self.assertEquals(4, len(self.board.fields))
     self.assertTrue(self.board.isCellAlive(1, 1))
Exemplo n.º 7
0
 def testGetFieldIJ(self):
     self.board.setCellAlive(0, 0)    
     self.board.setCellAlive(1, 0)   
     
     strBoard = """
                 # .
                 # .
             
                 """
     self.assertEquals(Board.newFromStr(strBoard, self.evManager), self.board)
Exemplo n.º 8
0
 def startBlinkerPatternWithStrDefinition(self):
     strBoard = """
                 . . . . .
                 . . # . .
                 . . # . .
                 . . # . .
                 . . . . .
             
                 """
     self.board = Board.newFromStr(strBoard)
     self.board.setCellAlive(1, 2)
     self.board.setCellAlive(2, 2)
     self.board.setCellAlive(3, 2)
Exemplo n.º 9
0
 def testBlinkerPaternWithStrBoardAsResult(self):
     resultBoard = """
                 . . . . .
                 . . . . .
                 . # # # .
                 . . . . .
                 . . . . .
               """
     self.board = Board.new(5, 5, self.evManager)
     self.board.setCellAlive(1, 2)
     self.board.setCellAlive(2, 2)
     self.board.setCellAlive(3, 2)
     
     self.board.newGeneration()
     self.assertTrue(Board.newFromStr(resultBoard, self.evManager) == self.board)
Exemplo n.º 10
0
 def testFirstRuleAnyLiveCellDiesWithLessThanTwoNeighbors(self):
     resultBoard = """
                 . . . . .
                 . . . . .
                 . . . . .
                 . . . . .
                 . . . . .
             
                 """
     self.board = Board.new(5, 5, self.evManager)
     self.board.setCellAlive(1, 2)
     self.board.setCellAlive(3, 2)
     self.board.setCellAlive(0, 4)
     self.board.setCellAlive(4, 4)
     self.board.newGeneration()
     self.assertEquals(Board.newFromStr(resultBoard, self.evManager), self.board)