Skip to content

Commit 1cc2c1e

Browse files
committed
fix tests
1 parent 434071f commit 1cc2c1e

2 files changed

Lines changed: 18 additions & 12 deletions

File tree

‎tests/test_fmi2.py‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,12 +1135,15 @@ def test_consecutive_simulation_with_initialize_false():
11351135
enter_continuous_time_mode before resuming integration. Regression
11361136
test to ensure this does not crash or corrupt the FMU state.
11371137
"""
1138-
fmu = load_fmu(REFERENCE_FMU_FMI2_PATH / "Feedthrough.fmu")
1138+
fmu = load_fmu(REFERENCE_FMU_FMI2_PATH / "BouncingBall.fmu")
11391139

1140-
fmu.set('Int32_input', 42)
1141-
fmu.simulate(0, 0.1, options={"ncp": 1})
1142-
assert fmu.get('Int32_output')[0] == 42
1140+
# Sanity check: model has state events
1141+
nstates, nevents = fmu.get_ode_sizes()
1142+
assert nevents == 1
1143+
1144+
res = fmu.simulate(0, 0.5, options={"ncp": 1})
1145+
assert fmu.get('h')[0] == res['h'][-1]
11431146

11441147
# Continue without re-initializing — exercises the fix
1145-
fmu.simulate(0.1, 0.2, options={"ncp": 1, "initialize": False})
1146-
assert fmu.get('Int32_output')[0] == 42
1148+
fmu.simulate(0.5, 1.0, options={"ncp": 1, "initialize": False})
1149+
assert fmu.get('h')[0] > 0.0

‎tests/test_fmi3_sim.py‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -361,12 +361,15 @@ def test_consecutive_simulation_with_initialize_false(self):
361361
enter_continuous_time_mode before resuming integration. Regression
362362
test to ensure this does not crash or corrupt the FMU state.
363363
"""
364-
fmu = load_fmu(FMI3_REF_FMU_PATH / "Feedthrough.fmu")
364+
fmu = load_fmu(FMI3_REF_FMU_PATH / "BouncingBall.fmu")
365+
366+
# Sanity check: model has state events
367+
nstates, nevents = fmu.get_ode_sizes()
368+
assert nevents > 0
365369

366-
fmu.set('Int32_input', 42)
367-
fmu.simulate(0, 0.1, options={"ncp": 1})
368-
assert fmu.get('Int32_output')[0] == 42
370+
res = fmu.simulate(0, 0.5, options={"ncp": 1})
371+
assert fmu.get('h')[0] == res['h'][-1]
369372

370373
# Continue without re-initializing — exercises the fix
371-
fmu.simulate(0.1, 0.2, options={"ncp": 1, "initialize": False})
372-
assert fmu.get('Int32_output')[0] == 42
374+
fmu.simulate(0.5, 1.0, options={"ncp": 1, "initialize": False})
375+
assert fmu.get('h')[0] > 0.0

0 commit comments

Comments
 (0)