2019-01-31 15:15:59 +00:00
|
|
|
import sys
|
|
|
|
sys.path.append('../src')
|
|
|
|
|
|
|
|
import cellular_automaton.ca_cell_state as cs
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
|
|
class TestCellState(unittest.TestCase):
|
|
|
|
|
2019-02-02 08:11:48 +00:00
|
|
|
def test_get_state_with_overflow(self):
|
|
|
|
cell_state = cs.CellState(initial_state=(0,))
|
|
|
|
cell_state.set_state_of_iteration(new_state=(1,), iteration=0)
|
|
|
|
self.assertEqual(tuple(cell_state.get_state_of_iteration(2)), (1,))
|
|
|
|
|
|
|
|
def test_set_state_with_overflow(self):
|
|
|
|
cell_state = cs.CellState(initial_state=(0,))
|
|
|
|
cell_state.set_state_of_iteration(new_state=(1,), iteration=2)
|
|
|
|
self.assertEqual(tuple(cell_state.get_state_of_iteration(0)), (1,))
|
|
|
|
|
|
|
|
def test_set_state_does_not_effect_all_slots(self):
|
|
|
|
cell_state = cs.CellState(initial_state=(0,))
|
|
|
|
cell_state.set_state_of_iteration(new_state=(1,), iteration=0)
|
|
|
|
self.assertEqual(tuple(cell_state.get_state_of_iteration(1)), (0,))
|
2019-01-31 15:15:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|