def test_eq_fTestSequence(self): for fileName in self.fTestSequence1: lg1 = lifegame.LifeGame(fileName) lg2 = lifegame.LifeGame(fileName) self.assertEqual( lg1, lg2, "File: {}\n{}\n\n".format( fileName, lifegame.LifeGame.sideBySide(lg1, lg2)))
def test_ne_constant_fTestSequence(self): lg1 = lifegame.LifeGame(self.fTestSequence1[0]) for fileName in self.fTestSequence1[1:]: lg2 = lifegame.LifeGame(fileName) self.assertNotEqual( lg1, lg2, "File: {}\n{}\n\n".format( fileName, lifegame.LifeGame.sideBySide(lg1, lg2)))
def test_init_SeatCountInvariant_fTestSequence(self): lg = lifegame.LifeGame(self.fTest1a) seatCount = str(lg).count('L') + str(lg).count('#') self.assertEqual(seatCount, len(lg.seatsUnresolved)) for fileName in self.fTestSequence1: lg2 = lifegame.LifeGame(fileName) self.assertEqual( seatCount, len(lg.seatsUnresolved), "File: {}\n{}\n\n".format( fileName, lifegame.LifeGame.sideBySide(lg, lg2)))
def test_generations_fTestSequence1(self): lg = lifegame.LifeGame(self.fTestSequence1[0]) gen = 0 for fileName in self.fTestSequence1: lgExpected = lifegame.LifeGame(fileName) self.assertEqual( lgExpected.seatingPlan, lg.seatingPlan, "Gen {}: {}\n{}\n\n".format( gen, fileName, lifegame.LifeGame.sideBySide(lgExpected, lg))) lg.calculateNextGen() lg.iterateGen() print(lifegame.LifeGame.sideBySide(lgExpected, lg), end='\n\n') gen += 1
def test_generations_fTestSequence2(self): lg = lifegame.LifeGame(self.fTestSequence2[0], immediateAdjacency=False, threshold=5) gen = 0 for fileName in self.fTestSequence2: lgExpected = lifegame.LifeGame(fileName) self.assertEqual( lgExpected.seatingPlan, lg.seatingPlan, "Gen {}: {}\n{}\n\n".format( gen, fileName, lifegame.LifeGame.sideBySide(lgExpected, lg))) print(lifegame.LifeGame.sideBySide(lgExpected, lg), end='\n\n') lg.calculateNextGen() lg.iterateGen() gen += 1
def test_ne_varying_fTestSequence(self): lg1 = lifegame.LifeGame(self.fTestSequence1[0]) for fileName in self.fTestSequence1[1:]: lg2 = lifegame.LifeGame(fileName) self.assertNotEqual(lg1, lg2, fileName) lg1 = lifegame.LifeGame(fileName)
def test_str_equal_fTestSequence(self): for fileName in self.fTestSequence1: lg1 = str(lifegame.LifeGame(fileName)) lg2 = str(lifegame.LifeGame(fileName)) self.assertEqual(lg1, lg2)
def test_init_neighbourCheck_fTest1a(self): lg = lifegame.LifeGame(self.fTest1a) seatCount = str(lg).count('L') + str(lg).count('#') self.assertEqual(seatCount, len(lg.seatsUnresolved))
def test_init_dimsCorrect_fTest1a(self): lg = lifegame.LifeGame(self.fTest1a) seatCount = str(lg).count('L') + str(lg).count('#') self.assertEqual(10, len(lg.seatingPlan), "Row count.") self.assertEqual(10, len(lg.seatingPlan[0]), "Column count.")