Skip to content

Commit

Permalink
Refactor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fintarin committed Mar 27, 2024
1 parent 5139fb5 commit fb1f396
Show file tree
Hide file tree
Showing 87 changed files with 248 additions and 495 deletions.
10 changes: 5 additions & 5 deletions tests/src/expressions/ExpressionTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@ TEST(ExpressionTests, equalsTest) {
// TODO: implement more tests
}

TEST(ExpressionTests, getClassTest) {
EXPECT_EQ(Expression::getClassStatic(), MathObjectClass("Expression"));
EXPECT_EQ(Expression::getClassStatic().getParent(), IExpression::getClassStatic());
}

TEST(ExpressionTests, variableVariablePlusOperatorTest) {
EXPECT_EQ(Variable("a") + Variable("a"), Expression("2a"));
EXPECT_EQ(Variable("a") + Variable("b"), Expression("a+b"));
Expand Down Expand Up @@ -161,3 +156,8 @@ TEST(ExpressionTests, expressionVariableDivideOperatorTest) {
EXPECT_EQ(Expression("a/b") / Variable("a"), Expression("1/b"));
EXPECT_EQ(Expression("b/c") / Variable("a"), Expression("b/c/a"));
}

TEST(ExpressionTests, getClassTest) {
EXPECT_EQ(Expression().getClass(), MathObjectClass("Expression"));
EXPECT_EQ(Expression().getClassStatic().getParent(), IExpression::getClassStatic());
}
4 changes: 3 additions & 1 deletion tests/src/expressions/FunctionExpressionTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,7 @@ TEST(FunctionExpressionTests, stringConstructorTest) {
}

TEST(FunctionExpressionTests, getClassTest) {
EXPECT_EQ(makeExpr(TestBinaryOperator(), Integer(0), Integer(0))->getClass(), MathObjectClass("FunctionExpression"));
auto expr = makeExpr(TestBinaryOperator(), Integer(0), Integer(0));
EXPECT_EQ(expr->getClass(), MathObjectClass("FunctionExpression"));
EXPECT_EQ(expr->getClass().getParent(), IExpression::getClassStatic());
}
5 changes: 4 additions & 1 deletion tests/src/expressions/unary/AbsExprTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@
using namespace fintamath;

TEST(AbsExprTests, getClassTest) {
EXPECT_EQ(absExpr(Integer(0).clone())->getClass(), MathObjectClass("AbsExpr"));
const auto expr = absExpr(Integer(0).clone());

EXPECT_EQ(expr->getClass(), MathObjectClass("AbsExpr"));
EXPECT_EQ(expr->getClass().getParent(), IUnaryExpression::getClassStatic());
}
9 changes: 3 additions & 6 deletions tests/src/functions/arithmetic/AbsTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

using namespace fintamath;

using F = Abs;
const F f;
const Abs f;

TEST(AbsTests, toStringTest) {
EXPECT_EQ(f.toString(), "abs");
Expand All @@ -26,12 +25,10 @@ TEST(AbsTests, getReturnClassTest) {
}

TEST(AbsTests, isVariadicTest) {
EXPECT_FALSE(F::isVariadicStatic());
EXPECT_FALSE(f.isVariadic());
}

TEST(AbsTests, isEvaluatableTest) {
EXPECT_TRUE(F::isEvaluatableStatic());
EXPECT_TRUE(f.isEvaluatable());
}

Expand Down Expand Up @@ -72,6 +69,6 @@ TEST(AbsTests, exprTest) {
}

TEST(AbsTests, getClassTest) {
EXPECT_EQ(F::getClassStatic(), MathObjectClass("Abs"));
EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic());
EXPECT_EQ(f.getClass(), MathObjectClass("Abs"));
EXPECT_EQ(f.getClass().getParent(), IFunction::getClassStatic());
}
11 changes: 3 additions & 8 deletions tests/src/functions/arithmetic/AddTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

using namespace fintamath;

using F = Add;
const F f;
const Add f;

TEST(AddTests, toStringTest) {
EXPECT_EQ(f.toString(), "+");
Expand All @@ -25,22 +24,18 @@ TEST(AddTests, getReturnClassTest) {
}

TEST(AddTests, isVariadicTest) {
EXPECT_FALSE(F::isVariadicStatic());
EXPECT_FALSE(f.isVariadic());
}

TEST(AddTests, isEvaluatableTest) {
EXPECT_TRUE(F::isEvaluatableStatic());
EXPECT_TRUE(f.isEvaluatable());
}

TEST(AddTests, getPriorityTest) {
EXPECT_EQ(F::getPriorityStatic(), IOperator::Priority::Addition);
EXPECT_EQ(f.getPriority(), IOperator::Priority::Addition);
}

TEST(AddTests, isAssociativeTest) {
EXPECT_TRUE(F::isAssociativeStatic());
EXPECT_TRUE(f.isAssociative());
}

Expand All @@ -64,6 +59,6 @@ TEST(AddTests, exprTest) {
}

TEST(AddTests, getClassTest) {
EXPECT_EQ(F::getClassStatic(), MathObjectClass("Add"));
EXPECT_EQ(F::getClassStatic().getParent(), IOperator::getClassStatic());
EXPECT_EQ(f.getClass(), MathObjectClass("Add"));
EXPECT_EQ(f.getClass().getParent(), IOperator::getClassStatic());
}
11 changes: 3 additions & 8 deletions tests/src/functions/arithmetic/DivTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

using namespace fintamath;

using F = Div;
const F f;
const Div f;

TEST(DivTests, toStringTest) {
EXPECT_EQ(f.toString(), "/");
Expand All @@ -25,22 +24,18 @@ TEST(DivTests, getReturnClassTest) {
}

TEST(DivTests, isVariadicTest) {
EXPECT_FALSE(F::isVariadicStatic());
EXPECT_FALSE(f.isVariadic());
}

TEST(DivTests, isEvaluatableTest) {
EXPECT_TRUE(F::isEvaluatableStatic());
EXPECT_TRUE(f.isEvaluatable());
}

TEST(DivTests, getPriorityTest) {
EXPECT_EQ(F::getPriorityStatic(), IOperator::Priority::Multiplication);
EXPECT_EQ(f.getPriority(), IOperator::Priority::Multiplication);
}

TEST(DivTests, isAssociativeTest) {
EXPECT_FALSE(F::isAssociativeStatic());
EXPECT_FALSE(f.isAssociative());
}

Expand All @@ -66,6 +61,6 @@ TEST(DivTests, exprTest) {
}

TEST(DivTests, getClassTest) {
EXPECT_EQ(F::getClassStatic(), MathObjectClass("Div"));
EXPECT_EQ(F::getClassStatic().getParent(), IOperator::getClassStatic());
EXPECT_EQ(f.getClass(), MathObjectClass("Div"));
EXPECT_EQ(f.getClass().getParent(), IOperator::getClassStatic());
}
9 changes: 3 additions & 6 deletions tests/src/functions/arithmetic/FracMixedTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

using namespace fintamath;

using F = FracMixed;
const F f;
const FracMixed f;

TEST(FracMixedTests, toStringTest) {
EXPECT_EQ(f.toString(), "frac");
Expand All @@ -25,12 +24,10 @@ TEST(FracMixedTests, getReturnClassTest) {
}

TEST(FracMixedTests, isVariadicTest) {
EXPECT_FALSE(F::isVariadicStatic());
EXPECT_FALSE(f.isVariadic());
}

TEST(FracMixedTests, isEvaluatableTest) {
EXPECT_TRUE(F::isEvaluatableStatic());
EXPECT_TRUE(f.isEvaluatable());
}

Expand All @@ -56,6 +53,6 @@ TEST(FracMixedTests, callTest) {
}

TEST(FracMixedTests, getClassTest) {
EXPECT_EQ(F::getClassStatic(), MathObjectClass("FracMixed"));
EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic());
EXPECT_EQ(f.getClass(), MathObjectClass("FracMixed"));
EXPECT_EQ(f.getClass().getParent(), IFunction::getClassStatic());
}
9 changes: 3 additions & 6 deletions tests/src/functions/arithmetic/FracTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

using namespace fintamath;

using F = Frac;
const F f;
const Frac f;

TEST(FracTests, toStringTest) {
EXPECT_EQ(f.toString(), "frac");
Expand All @@ -25,12 +24,10 @@ TEST(FracTests, getReturnClassTest) {
}

TEST(FracTests, isVariadicTest) {
EXPECT_FALSE(F::isVariadicStatic());
EXPECT_FALSE(f.isVariadic());
}

TEST(FracTests, isEvaluatableTest) {
EXPECT_TRUE(F::isEvaluatableStatic());
EXPECT_TRUE(f.isEvaluatable());
}

Expand All @@ -49,6 +46,6 @@ TEST(FracTests, callTest) {
}

TEST(FracTests, getClassTest) {
EXPECT_EQ(F::getClassStatic(), MathObjectClass("Frac"));
EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic());
EXPECT_EQ(f.getClass(), MathObjectClass("Frac"));
EXPECT_EQ(f.getClass().getParent(), IFunction::getClassStatic());
}
11 changes: 3 additions & 8 deletions tests/src/functions/arithmetic/MulTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

using namespace fintamath;

using F = Mul;
const F f;
const Mul f;

TEST(MulTests, toStringTest) {
EXPECT_EQ(f.toString(), "*");
Expand All @@ -24,22 +23,18 @@ TEST(MulTests, getReturnClassTest) {
}

TEST(MulTests, isVariadicTest) {
EXPECT_FALSE(F::isVariadicStatic());
EXPECT_FALSE(f.isVariadic());
}

TEST(MulTests, isEvaluatableTest) {
EXPECT_TRUE(F::isEvaluatableStatic());
EXPECT_TRUE(f.isEvaluatable());
}

TEST(MulTests, getPriorityTest) {
EXPECT_EQ(F::getPriorityStatic(), IOperator::Priority::Multiplication);
EXPECT_EQ(f.getPriority(), IOperator::Priority::Multiplication);
}

TEST(MulTests, isAssociativeTest) {
EXPECT_TRUE(F::isAssociativeStatic());
EXPECT_TRUE(f.isAssociative());
}

Expand All @@ -62,6 +57,6 @@ TEST(MulTests, exprTest) {
}

TEST(MulTests, getClassTest) {
EXPECT_EQ(F::getClassStatic(), MathObjectClass("Mul"));
EXPECT_EQ(F::getClassStatic().getParent(), IOperator::getClassStatic());
EXPECT_EQ(f.getClass(), MathObjectClass("Mul"));
EXPECT_EQ(f.getClass().getParent(), IOperator::getClassStatic());
}
11 changes: 3 additions & 8 deletions tests/src/functions/arithmetic/NegTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

using namespace fintamath;

using F = Neg;
const F f;
const Neg f;

TEST(NegTests, toStringTest) {
EXPECT_EQ(f.toString(), "-");
Expand All @@ -24,22 +23,18 @@ TEST(NegTests, getReturnClassTest) {
}

TEST(NegTests, isVariadicTest) {
EXPECT_FALSE(F::isVariadicStatic());
EXPECT_FALSE(f.isVariadic());
}

TEST(NegTests, isEvaluatableTest) {
EXPECT_TRUE(F::isEvaluatableStatic());
EXPECT_TRUE(f.isEvaluatable());
}

TEST(NegTests, getPriorityTest) {
EXPECT_EQ(F::getPriorityStatic(), IOperator::Priority::PrefixUnary);
EXPECT_EQ(f.getPriority(), IOperator::Priority::PrefixUnary);
}

TEST(NegTests, isAssociativeTest) {
EXPECT_FALSE(F::isAssociativeStatic());
EXPECT_FALSE(f.isAssociative());
}

Expand All @@ -60,6 +55,6 @@ TEST(NegTests, exprTest) {
}

TEST(NegTests, getClassTest) {
EXPECT_EQ(F::getClassStatic(), MathObjectClass("Neg"));
EXPECT_EQ(F::getClassStatic().getParent(), IOperator::getClassStatic());
EXPECT_EQ(f.getClass(), MathObjectClass("Neg"));
EXPECT_EQ(f.getClass().getParent(), IOperator::getClassStatic());
}
9 changes: 3 additions & 6 deletions tests/src/functions/arithmetic/SignTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

using namespace fintamath;

using F = Sign;
const F f;
const Sign f;

TEST(SignTests, toStringTest) {
EXPECT_EQ(f.toString(), "sign");
Expand All @@ -26,12 +25,10 @@ TEST(SignTests, getReturnClassTest) {
}

TEST(SignTests, isVariadicTest) {
EXPECT_FALSE(F::isVariadicStatic());
EXPECT_FALSE(f.isVariadic());
}

TEST(SignTests, isEvaluatableTest) {
EXPECT_TRUE(F::isEvaluatableStatic());
EXPECT_TRUE(f.isEvaluatable());
}

Expand Down Expand Up @@ -70,6 +67,6 @@ TEST(SignTests, exprTest) {
}

TEST(SignTests, getClassTest) {
EXPECT_EQ(F::getClassStatic(), MathObjectClass("Sign"));
EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic());
EXPECT_EQ(f.getClass(), MathObjectClass("Sign"));
EXPECT_EQ(f.getClass().getParent(), IFunction::getClassStatic());
}
11 changes: 3 additions & 8 deletions tests/src/functions/arithmetic/SubTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

using namespace fintamath;

using F = Sub;
const F f;
const Sub f;

TEST(SubTests, toStringTest) {
EXPECT_EQ(f.toString(), "-");
Expand All @@ -25,22 +24,18 @@ TEST(SubTests, getReturnClassTest) {
}

TEST(SubTests, isVariadicTest) {
EXPECT_FALSE(F::isVariadicStatic());
EXPECT_FALSE(f.isVariadic());
}

TEST(SubTests, isEvaluatableTest) {
EXPECT_TRUE(F::isEvaluatableStatic());
EXPECT_TRUE(f.isEvaluatable());
}

TEST(SubTests, getPriorityTest) {
EXPECT_EQ(F::getPriorityStatic(), IOperator::Priority::Addition);
EXPECT_EQ(f.getPriority(), IOperator::Priority::Addition);
}

TEST(SubTests, isAssociativeTest) {
EXPECT_FALSE(F::isAssociativeStatic());
EXPECT_FALSE(f.isAssociative());
}

Expand All @@ -64,6 +59,6 @@ TEST(SubTests, exprTest) {
}

TEST(SubTests, getClassTest) {
EXPECT_EQ(F::getClassStatic(), MathObjectClass("Sub"));
EXPECT_EQ(F::getClassStatic().getParent(), IOperator::getClassStatic());
EXPECT_EQ(f.getClass(), MathObjectClass("Sub"));
EXPECT_EQ(f.getClass().getParent(), IOperator::getClassStatic());
}
Loading

0 comments on commit fb1f396

Please sign in to comment.