Unit tests for getting and setting cell temperature. Refs #1223

This commit is contained in:
aprilnovak 2019-05-06 13:38:07 -07:00
parent 18b225f14d
commit 3cb99504fc
2 changed files with 14 additions and 2 deletions

View file

@ -143,7 +143,7 @@ class Cell(_FortranObjectWithID):
"""
if instance is not None:
instance = c_int32(instance)
instance = c_int32(instance)
T = c_double()
_dll.openmc_cell_get_temperature(self._index, instance, T)
@ -160,7 +160,11 @@ class Cell(_FortranObjectWithID):
Which instance of the cell
"""
_dll.openmc_cell_set_temperature(self._index, T, c_int32(instance))
if instance is not None:
instance = c_int32(instance)
_dll.openmc_cell_set_temperature(self._index, T, instance)
class _CellMapping(Mapping):

View file

@ -75,6 +75,14 @@ def test_cell(capi_init):
assert str(cell) == 'Cell[0]'
def test_cell_temperature(capi_init):
cell = openmc.capi.cells[1]
cell.set_temperature(100.0, 0)
assert cell.get_temperature(0) == 100.0
cell.set_temperature(200)
assert cell.get_temperature() == 200.0
def test_new_cell(capi_init):
with pytest.raises(exc.AllocationError):
openmc.capi.Cell(1)