Skip to content

Commit

Permalink
Add more testcases for compute_distance2boundary.
Browse files Browse the repository at this point in the history
- The method has several paths controlled by conditional
  statements, so for complete coverage of the method, it
  has been parametrized with pytest - four separate test
  cases run through for different paths within.

- This method has been covered. Each and every path that
  leads to completion (return) has been executed.
  • Loading branch information
karandesai-96 committed Mar 28, 2016
1 parent 9f8d4ae commit 8101adb
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tardis/montecarlo/tests/test_cmontecarlo.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,15 @@ def __init__(self, **kwargs):


@pytest.mark.parametrize(
['mu', 'r', 'r_inner', 'r_outer', 'expected'],
[(0.3, 7.5e14, [6.912e14, 8.64e14], [8.64e14, 1.0368e15], 259376919351035.88)]
['mu', 'r', 'recently_crossed_boundary', 'r_inner', 'r_outer', 'expected'],
[(0.3, 7.5e14, 1, [6.912e14, 8.64e14], [8.64e14, 1.0368e15], 259376919351035.88),
(0.3, 7.5e14, 0, [6.912e14, 8.64e14], [8.64e14, 1.0368e15], 259376919351035.88),
(-0.3, 7.5e13, 0, [6.912e14, 8.64e14], [8.64e14, 1.0368e15], -838532664885601.1),
(-0.3, 7.5e14, 0, [6.912e14, 8.64e14], [8.64e14, 1.0368e15], -259376919351035.88)]
)
def test_compute_distance2boundary(mu, r, r_inner, r_outer, expected):
packet = RPacket(mu=mu, r=r, current_shell_id=0, recently_crossed_boundary=1, next_shell_id=1)
def test_compute_distance2boundary(mu, r, recently_crossed_boundary, r_inner, r_outer, expected):
packet = RPacket(mu=mu, r=r, current_shell_id=0, next_shell_id=1,
recently_crossed_boundary=recently_crossed_boundary)
model = StorageModel(r_inner=npclib.as_ctypes(np.array(r_inner)),
r_outer=npclib.as_ctypes(np.array(r_outer)))

Expand Down

0 comments on commit 8101adb

Please sign in to comment.