Skip to content

Commit 92861f7

Browse files
committed
Add test for comments
1 parent 8a9fd5b commit 92861f7

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

tests/test_syntax.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from textwrap import dedent
22

3+
from pytest import approx
34
from openmc_mcnp_adapter import mcnp_str_to_model
45

56

@@ -23,3 +24,28 @@ def test_repeat_shortcut():
2324
# Make sure E, F, G, H, J, and K parameters are 0.0
2425
for attr in 'efghj':
2526
assert getattr(surf, attr) == 0.0
27+
28+
29+
def test_comments():
30+
mcnp_str = dedent("""
31+
title
32+
c This is a comment line
33+
1 1 -5.0 -1 $ This is an end-of-line comment
34+
35+
c surface block
36+
1 so 3.0 $ Another comment
37+
38+
m1 1001.80c 3.0 $ Material comment
39+
""")
40+
model = mcnp_str_to_model(mcnp_str)
41+
surf = model.geometry.get_all_surfaces()[1]
42+
cell = model.geometry.get_all_cells()[1]
43+
mat = model.materials[0]
44+
45+
# Sanity checks
46+
assert surf.r == 3.0
47+
assert surf.x0 == 0.0
48+
assert cell.id == 1
49+
assert str(cell.region) == "-1"
50+
assert 'H1' in mat.get_nuclide_densities()
51+
assert mat.get_mass_density() == approx(5.0)

0 commit comments

Comments
 (0)