コード例 #1
0
ファイル: BoardTest.py プロジェクト: victorhg/pyconway
 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)
コード例 #2
0
ファイル: BoardTest.py プロジェクト: victorhg/pyconway
 def testLiveCellWithFourNeighboursDies(self):
     resultBoard = """
                 . . . . 
                 . . . # 
                 . # . # 
                 . # # # 
               """
     startBoard = """
                 . . . . 
                 . . . # 
                 . # # # 
                 . . # . 
               """
     self.board = Board.newFromStr(startBoard, self.evManager)
     self.board.newGeneration()
     self.assertTrue(Board.newFromStr(resultBoard, self.evManager) == self.board)
コード例 #3
0
ファイル: BoardTest.py プロジェクト: victorhg/pyconway
 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)
コード例 #4
0
ファイル: BoardTest.py プロジェクト: victorhg/pyconway
 def testEquals2x2OnGeneration(self):
     strBoard1 = """
                 . #
                 # #
             
                 """
     
     strBoard2 = """
                 # #
                 # #
             
                 """
     
     board1 = Board.newFromStr(strBoard1, self.evManager)
     board1.newGeneration()
     board2 = Board.newFromStr(strBoard2, self.evManager)
     self.assertTrue(board1 == board2)
コード例 #5
0
ファイル: BoardTest.py プロジェクト: victorhg/pyconway
 def testShouldBeAbleToDefineBoardWithString(self):
     strBoard = """
                 . .
                 . .
             
                 """
     self.board = Board.newFromStr(strBoard, self.evManager)
     self.assertEquals(4, len(self.board.fields))
コード例 #6
0
ファイル: BoardTest.py プロジェクト: victorhg/pyconway
 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))
コード例 #7
0
ファイル: BoardTest.py プロジェクト: victorhg/pyconway
 def testGetFieldIJ(self):
     self.board.setCellAlive(0, 0)    
     self.board.setCellAlive(1, 0)   
     
     strBoard = """
                 # .
                 # .
             
                 """
     self.assertEquals(Board.newFromStr(strBoard, self.evManager), self.board)
コード例 #8
0
ファイル: BoardTest.py プロジェクト: victorhg/pyconway
 def startBlinkerPatternWithStrDefinition(self):
     strBoard = """
                 . . . . .
                 . . # . .
                 . . # . .
                 . . # . .
                 . . . . .
             
                 """
     self.board = Board.newFromStr(strBoard)
     self.board.setCellAlive(1, 2)
     self.board.setCellAlive(2, 2)
     self.board.setCellAlive(3, 2)
コード例 #9
0
ファイル: BoardTest.py プロジェクト: victorhg/pyconway
 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)
コード例 #10
0
ファイル: BoardTest.py プロジェクト: victorhg/pyconway
 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)