You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gameoflife/tests/test_gameoflife.py

18 lines
730 B

import pytest
import numpy as np
import conway.gameoflife as gol
class TestState:
def test_neighbours(self):
state = gol.State(10, 10)
n1 = np.array([[1, 1, 1], [1, 1, 1], [1, 1, 1]])
assert state.checkNeighbours(n1, 1, 1) == 8
assert state.checkNeighbours(n1, 1, 1, neighbourhood="neumann") == 4
n2 = np.array([[0, 0, 0], [0, 0, 0], [0, 0, 0]])
assert state.checkNeighbours(n2, 1, 1) == 0
assert state.checkNeighbours(n2, 1, 1, neighbourhood="neumann") == 0
n3 = np.array([[1, 0, 1], [0, 1, 0], [1, 0, 1]])
assert state.checkNeighbours(n3, 1, 1, neighbourhood="moore") == 4
assert state.checkNeighbours(n3, 1, 1, neighbourhood="neumann") == 0