Browse Source

Add test and fix bug RationalFunction to Expression

tempestpy_adaptions
Jip Spel 6 years ago
parent
commit
6695f64460
  1. 2
      src/storm/storage/expressions/RationalFunctionToExpression.cpp
  2. 21
      src/test/storm/storage/ExpressionTest.cpp

2
src/storm/storage/expressions/RationalFunctionToExpression.cpp

@ -58,8 +58,8 @@ namespace storm {
result = result + nominatorPartExpr; result = result + nominatorPartExpr;
} }
} }
result = result / denominatorVal;
} }
result = result / denominatorVal;
return result; return result;
} }
template class RationalFunctionToExpression<storm::RationalFunction>; template class RationalFunctionToExpression<storm::RationalFunction>;

21
src/test/storm/storage/ExpressionTest.cpp

@ -403,3 +403,24 @@ TEST(Expression, RationalFunctionToExpressionTest) {
ASSERT_NO_THROW(result.simplify()); ASSERT_NO_THROW(result.simplify());
EXPECT_EQ(rationalFunction.toString(), result.toString()); EXPECT_EQ(rationalFunction.toString(), result.toString());
} }
TEST(Expression, RationalFunctionToExpressionTest_no_params) {
storm::parser::ValueParser<storm::RationalFunction> parser;
parser.addParameter("p");
auto rationalFunction1 = parser.parseValue("(p + 380)/3125");
auto rationalFunction2 = parser.parseValue("(p)/3125");
auto rationalFunction = rationalFunction1 - rationalFunction2;
std::shared_ptr<storm::expressions::ExpressionManager> manager(new storm::expressions::ExpressionManager());
auto transformer = storm::expressions::RationalFunctionToExpression<storm::RationalFunction>(manager);
storm::expressions::Expression expr;
EXPECT_NO_THROW(expr = transformer.toExpression(rationalFunction));
auto base = storm::expressions::ExpressionEvaluator<storm::RationalFunction>(*manager);
storm::expressions::ToRationalFunctionVisitor<storm::RationalFunction> visitor(base);
ASSERT_NO_THROW(rationalFunction.simplify());
storm::RationalFunction result;
ASSERT_NO_THROW(result = visitor.toRationalFunction(expr));
ASSERT_NO_THROW(result.simplify());
EXPECT_EQ(rationalFunction.toString(), result.toString());
}
Loading…
Cancel
Save