From b834eae02b73672907b666622362f9e0f8aac580 Mon Sep 17 00:00:00 2001 From: fintarin Date: Wed, 19 Jul 2023 00:25:55 +0300 Subject: [PATCH] Improve coverage --- .../expressions/interfaces/IPolynomExpression.cpp | 8 ++------ src/fintamath/expressions/polynomial/AddExpression.cpp | 2 +- tests/src/expressions/ExpressionTests.cpp | 4 ++++ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/fintamath/expressions/interfaces/IPolynomExpression.cpp b/src/fintamath/expressions/interfaces/IPolynomExpression.cpp index f9569e01f..2b4d26054 100644 --- a/src/fintamath/expressions/interfaces/IPolynomExpression.cpp +++ b/src/fintamath/expressions/interfaces/IPolynomExpression.cpp @@ -342,12 +342,8 @@ int IPolynomExpression::comparatorExpressionAndNonExpression(const std::shared_p case IOperator::Priority::Multiplication: { static const ArgumentPtr one = Integer(1).clone(); ArgumentPtr rhsExpr = makeExpr(*lhsOper, rhs, one); - - if (int comp = comparator(lhs, rhsExpr)) { - return isTermsOrderInversed() ? comp * -1 : comp; - } - - break; + int comp = comparator(lhs, rhsExpr); + return isTermsOrderInversed() ? comp * -1 : comp; } default: break; diff --git a/src/fintamath/expressions/polynomial/AddExpression.cpp b/src/fintamath/expressions/polynomial/AddExpression.cpp index 0312a1218..d65eec718 100644 --- a/src/fintamath/expressions/polynomial/AddExpression.cpp +++ b/src/fintamath/expressions/polynomial/AddExpression.cpp @@ -187,7 +187,7 @@ ArgumentPtr AddExpression::simplifyMulLogarithms(const IFunction & /*func*/, con mulExpr = lhsExpr; logExpr = rhsExpr; } - else if (is(rhsExpr->getFunction()) && is(lhsExpr->getFunction())) { + else if (is(lhsExpr->getFunction()) && is(rhsExpr->getFunction())) { mulExpr = rhsExpr; logExpr = lhsExpr; } diff --git a/tests/src/expressions/ExpressionTests.cpp b/tests/src/expressions/ExpressionTests.cpp index 3887d6455..e87ff7a2b 100644 --- a/tests/src/expressions/ExpressionTests.cpp +++ b/tests/src/expressions/ExpressionTests.cpp @@ -494,6 +494,7 @@ TEST(ExpressionTests, stringConstructorTest) { EXPECT_EQ(Expression("((1=2) -> (1=2) & ~(1=1)) !<-> ((1=1) <-> ~((1=2) | (1=1)))").toString(), "True"); EXPECT_EQ(Expression("False|1=1").toString(), "True"); EXPECT_EQ(Expression("1=1|False").toString(), "True"); + EXPECT_EQ(Expression("a>b|a").toString(), "a - b > 0 | a"); EXPECT_EQ(Expression("~(x = 1)").toString(), "x - 1 != 0"); EXPECT_EQ(Expression("~(x != 1)").toString(), "x - 1 = 0"); @@ -635,8 +636,11 @@ TEST(ExpressionTests, stringConstructorTest) { EXPECT_EQ(Expression("log(2.3,(E)/(20000.1EE)) + log(2.3,20000.1E)").toString(), "0"); EXPECT_EQ(Expression("log(2, 3) + log(3, 4)").toString(), "log(3, 4) + log(2, 3)"); EXPECT_EQ(Expression("x log(2, 3) + log(2, 5)").toString(), "log(2, 5 3^x)"); + EXPECT_EQ(Expression("x log(2, 3) + log(2, 5a)").toString(), "log(2, 5 a 3^x)"); EXPECT_EQ(Expression("log(2, 3) + 3log(3, 4)").toString(), "3 log(3, 4) + log(2, 3)"); EXPECT_EQ(Expression("3log(2x, 3) + log(3, 4)").toString(), "3 log(2 x, 3) + log(3, 4)"); + EXPECT_EQ(Expression("3log(2x, 3) + 4log(3, 4)").toString(), "3 log(2 x, 3) + 4 log(3, 4)"); + EXPECT_EQ(Expression("3log(2x, 3) + 5log(2x, 4)").toString(), "log(2 x, 27648)"); EXPECT_EQ(Expression("sin(asin(x))").toString(), "x"); EXPECT_EQ(Expression("cos(acos(x))").toString(), "x");