diff --git a/src/test/storm/storage/ExpressionTest.cpp b/src/test/storm/storage/ExpressionTest.cpp index 27e4e7d7a..ed6d33152 100644 --- a/src/test/storm/storage/ExpressionTest.cpp +++ b/src/test/storm/storage/ExpressionTest.cpp @@ -6,7 +6,13 @@ #include "storm/storage/expressions/ExpressionManager.h" #include "storm/storage/expressions/LinearityCheckVisitor.h" #include "storm/storage/expressions/SimpleValuation.h" +#include "storm/storage/expressions/ExpressionEvaluator.h" +#include "storm/storage/expressions/ValueTypeToExpression.h" #include "storm/exceptions/InvalidTypeException.h" +#include "storm/adapters/RationalFunctionAdapter.h" +#include "storm-parsers/parser/ValueParser.h" +#include "storm/storage/expressions/ToRationalFunctionVisitor.h" + TEST(Expression, FactoryMethodTest) { std::shared_ptr manager(new storm::expressions::ExpressionManager()); @@ -369,3 +375,31 @@ TEST(Expression, VisitorTest) { storm::expressions::LinearityCheckVisitor visitor; EXPECT_TRUE(visitor.check(tempExpression)); } + +TEST(Expression, ValueTypeToExpressionTest) { + storm::parser::ValueParser parser; + parser.addParameter("p"); + parser.addParameter("q"); + auto rationalFunction = parser.parseValue("((5*p^(3))+(q*p*7)+2)/2"); + + std::shared_ptr manager(new storm::expressions::ExpressionManager()); + auto transformer = storm::expressions::ValueTypeToExpression(manager); + + storm::expressions::Expression expr; + EXPECT_NO_THROW(expr = transformer.toExpression(rationalFunction)); + auto base = storm::expressions::ExpressionEvaluator(*manager); + storm::expressions::ToRationalFunctionVisitor 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()); + + rationalFunction = parser.parseValue("(5*((p^(3))+(q*p)))/2"); + transformer = storm::expressions::ValueTypeToExpression(manager); + EXPECT_NO_THROW(expr = transformer.toExpression(rationalFunction)); + ASSERT_NO_THROW(rationalFunction.simplify()); + ASSERT_NO_THROW(result = visitor.toRationalFunction(expr)); + ASSERT_NO_THROW(result.simplify()); + EXPECT_EQ(rationalFunction.toString(), result.toString()); +} \ No newline at end of file