Skip to content

Commit

Permalink
Add test for empty input for block read/write
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminRodenberg committed Nov 17, 2020
1 parent 5fbf57b commit 86fc5d4
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/test_bindings_module.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,13 @@ class TestBindings(TestCase):
read_data = solver_interface.read_block_scalar_data(1, np.array([1, 2, 3]))
self.assertTrue(np.array_equal(write_data, read_data))

def test_read_write_block_scalar_data_empty(self):
solver_interface = precice.Interface("test", "dummy.xml", 0, 1)
write_data = np.array([])
solver_interface.write_block_scalar_data(1, [], write_data)
read_data = solver_interface.read_block_scalar_data(1, [])
self.assertTrue(len(read_data) == 0)

def test_read_write_block_scalar_data_non_contiguous(self):
"""
Tests behaviour of solver interface, if a non contiguous array is passed to the interface.
Expand Down Expand Up @@ -224,6 +231,13 @@ class TestBindings(TestCase):
read_data = solver_interface.read_block_vector_data(1, np.array([1, 2]))
self.assertTrue(np.array_equal(write_data, read_data))

def test_read_write_block_vector_data_empty(self):
solver_interface = precice.Interface("test", "dummy.xml", 0, 1)
write_data = np.array([])
solver_interface.write_block_vector_data(1, [], write_data)
read_data = solver_interface.read_block_vector_data(1, [])
self.assertTrue(len(read_data) == 0)

def test_read_write_block_vector_data_list(self):
solver_interface = precice.Interface("test", "dummy.xml", 0, 1)
write_data = [[3, 7, 8], [7 ,6, 5]]
Expand Down

0 comments on commit 86fc5d4

Please sign in to comment.