def test_can_handle_bad_matrix(self): game = GameOfLife() bad_field = [[0, 0], [0]] msg = 'invalid string entered' with self.assertRaisesRegex(ValueError, msg): game.start(bad_field)
def test_start_2x2_last_point_is_dead(self): game = GameOfLife() field_test = [[1, 1], [1, 0]] result = game.start(field_test) correct_field = [[1, 1], [1, 1]] self.assertTrue(result == correct_field)
def test_start_2x2_two_points_on_the_first_line_are_live(self): game = GameOfLife() field_test = [[1, 1], [0, 0]] result = game.start(field_test) correct_field = [[0, 0], [0, 0]] self.assertTrue(result == correct_field)
def test_start_2x2_first_point_live(self): game = GameOfLife() field_test = [[1, 0], [0, 0]] result = game.start(field_test) correct_field = [[0, 0], [0, 0]] self.assertTrue(result == correct_field)
def test_start_3x3_living_square(self): game = GameOfLife() field_test = [[1, 1, 0], [1, 0, 0], [0, 0, 0]] result = game.start(field_test) correct_field = [[1, 1, 0], [1, 1, 0], [0, 0, 0]] self.assertTrue(result == correct_field)
def test_start_4x8_column(self): game = GameOfLife() field_test = [[0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]] result = game.start(field_test) correct_field = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]] self.assertTrue(result == correct_field)
def test_can_create_game_of_life(self): game = GameOfLife() self.assertTrue(isinstance(game, GameOfLife))
def test_start_2x2_all_points_are_dead(self): game = GameOfLife() field_test = [[0, 0], [0, 0]] result = game.start(field_test) self.assertTrue(result == field_test)
def compute_next_step(self): self.logger.log('Button clicked') game = GameOfLife() self.convert_field_to_binary(self.current_color_field) self.next_binary_field = game.start(self.current_binary_field) self.convert_field_to_color()
def compute_next_step(self): game = GameOfLife() self.convert_field_to_binary(self.current_color_field) self.next_binary_field = game.start(self.current_binary_field) self.convert_field_to_color()