Skip to content

Asserts on Real values with test models are too tight #4554

@casella

Description

@casella

There are two tests in ModelicaTest.Fluid.TestComponents that have too tight asserts. One is Machines.TestLinearPower:

assert(p >= 23 and p <= 23, "Error in linearPower");

which is a numerical hazard, because p is computed by a linear equation, so the actual computed value could be something like 23.000000000001 or 29.999999999999 or something like that, which would of course be OK but would trigger the assertion failure.

The other one is ModelicaTest.Fluid.TestComponents.Pipes.DynamicPipeEnergyConservationCheck2:

assert(time < 500 or Modelica.Math.isEqual(total_AV_B_a, total_AV_B_b, 1), "Energy not conserved!");
assert(time < 500 or Modelica.Math.isEqual(total_A_VB_a, total_A_VB_b, 1), "Energy not conserved!");
assert(time < 500 or Modelica.Math.isEqual(total_AV_VB_a, total_AV_VB_b, 1), "Energy not conserved!");
assert(time < 500 or Modelica.Math.isEqual(total_A_V_B_a, total_A_V_B_b, 1), "Energy not conserved!");

where it is not clear whether the second part of the assertions will ever be checked, since

Metadata

Metadata

Assignees

Labels

L: ModelicaTestIssue addresses ModelicaTest, ModelicaTestConversion4 or ModelicaTestOverdetermined

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions