Skip to content

Commit

Permalink
Rename PowerF to PowerFunction
Browse files Browse the repository at this point in the history
  • Loading branch information
fintarin committed Oct 25, 2023
1 parent 70e5343 commit 73e6d8c
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion include/fintamath/core/MathObjectTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class MathObjectType {
Derivative,
Integral,
Frac,
PowF,
PowerFunction,
Floor,
Ceil,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

namespace fintamath {

class PowF : public IFunctionCRTP<IArithmetic, PowF, IArithmetic, IArithmetic> {
class PowerFunction : public IFunctionCRTP<IArithmetic, PowerFunction, IArithmetic, IArithmetic> {
public:
std::string toString() const override {
return "pow";
}

static MathObjectType getTypeStatic() {
return MathObjectType::PowF;
return MathObjectType::PowerFunction;
}

protected:
Expand Down
4 changes: 2 additions & 2 deletions src/fintamath/config/ExpressionConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#include "fintamath/functions/other/Percent.hpp"
#include "fintamath/functions/powers/Exp.hpp"
#include "fintamath/functions/powers/Pow.hpp"
#include "fintamath/functions/powers/PowF.hpp"
#include "fintamath/functions/powers/PowerFunction.hpp"
#include "fintamath/functions/powers/Root.hpp"
#include "fintamath/functions/powers/Sqrt.hpp"
#include "fintamath/functions/trigonometry/Acos.hpp"
Expand Down Expand Up @@ -172,7 +172,7 @@ struct ExpressionConfig {
return PowExpression(std::move(args.front()), std::move(args.back())).clone();
});

Expression::registerFunctionExpressionMaker<PowF>([](ArgumentPtrVector &&args) {
Expression::registerFunctionExpressionMaker<PowerFunction>([](ArgumentPtrVector &&args) {
return PowExpression(std::move(args.front()), std::move(args.back())).clone();
});

Expand Down
4 changes: 2 additions & 2 deletions src/fintamath/config/ParserConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
#include "fintamath/functions/other/Percent.hpp"
#include "fintamath/functions/powers/Exp.hpp"
#include "fintamath/functions/powers/Pow.hpp"
#include "fintamath/functions/powers/PowF.hpp"
#include "fintamath/functions/powers/PowerFunction.hpp"
#include "fintamath/functions/powers/Root.hpp"
#include "fintamath/functions/powers/Sqrt.hpp"
#include "fintamath/functions/trigonometry/Acos.hpp"
Expand Down Expand Up @@ -225,7 +225,7 @@ struct ParserConfig {
IFunction::registerType<Derivative>();
IFunction::registerType<Integral>();
IFunction::registerType<Frac>();
IFunction::registerType<PowF>();
IFunction::registerType<PowerFunction>();
IFunction::registerType<Floor>();
IFunction::registerType<Ceil>();

Expand Down
11 changes: 0 additions & 11 deletions src/fintamath/functions/powers/PowF.cpp

This file was deleted.

11 changes: 11 additions & 0 deletions src/fintamath/functions/powers/PowerFunction.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "fintamath/functions/powers/PowerFunction.hpp"

#include "fintamath/functions/powers/Pow.hpp"

namespace fintamath {

std::unique_ptr<IMathObject> PowerFunction::call(const ArgumentRefVector &argsVect) const {
return Pow()(argsVect);
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "gtest/gtest.h"

#include "fintamath/functions/powers/PowF.hpp"
#include "fintamath/functions/powers/PowerFunction.hpp"

#include "fintamath/core/IArithmetic.hpp"
#include "fintamath/exceptions/UndefinedException.hpp"
Expand All @@ -12,17 +12,17 @@

using namespace fintamath;

const PowF f;
const PowerFunction f;

TEST(PowFTests, toStringTest) {
TEST(PowerFunctionTests, toStringTest) {
EXPECT_EQ(f.toString(), "pow");
}

TEST(PowFTests, getFunctionTypeTest) {
TEST(PowerFunctionTests, getFunctionTypeTest) {
EXPECT_EQ(f.getFunctionType(), IFunction::Type::Binary);
}

TEST(PowFTests, callTest) {
TEST(PowerFunctionTests, callTest) {
EXPECT_EQ(f(Integer(3), Integer(2))->toString(), "9");
EXPECT_EQ(f(Rational(-10), Rational(-3))->toString(), "-1/1000");

Expand All @@ -36,7 +36,7 @@ TEST(PowFTests, callTest) {
EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException);
}

TEST(PowFTests, doArgsMatchTest) {
TEST(PowerFunctionTests, doArgsMatchTest) {
Integer a;

EXPECT_FALSE(f.doArgsMatch({}));
Expand All @@ -45,19 +45,19 @@ TEST(PowFTests, doArgsMatchTest) {
EXPECT_FALSE(f.doArgsMatch({a, a, a}));
}

TEST(PowFTests, equalsTest) {
TEST(PowerFunctionTests, equalsTest) {
EXPECT_EQ(f, f);
EXPECT_EQ(f, PowF());
EXPECT_EQ(PowF(), f);
EXPECT_EQ(f, cast<IMathObject>(PowF()));
EXPECT_EQ(cast<IMathObject>(PowF()), f);
EXPECT_EQ(f, PowerFunction());
EXPECT_EQ(PowerFunction(), f);
EXPECT_EQ(f, cast<IMathObject>(PowerFunction()));
EXPECT_EQ(cast<IMathObject>(PowerFunction()), f);
EXPECT_NE(f, Sub());
EXPECT_NE(Sub(), f);
EXPECT_NE(f, UnaryPlus());
EXPECT_NE(UnaryPlus(), f);
}

TEST(PowFTests, getTypeTest) {
EXPECT_EQ(PowF::getTypeStatic(), MathObjectType::PowF);
EXPECT_EQ(PowF().getType(), MathObjectType::PowF);
TEST(PowerFunctionTests, getTypeTest) {
EXPECT_EQ(PowerFunction::getTypeStatic(), MathObjectType::PowerFunction);
EXPECT_EQ(PowerFunction().getType(), MathObjectType::PowerFunction);
}
4 changes: 2 additions & 2 deletions tests/src/parser/ParserTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
#include "fintamath/functions/other/Percent.hpp"
#include "fintamath/functions/powers/Exp.hpp"
#include "fintamath/functions/powers/Pow.hpp"
#include "fintamath/functions/powers/PowF.hpp"
#include "fintamath/functions/powers/PowerFunction.hpp"
#include "fintamath/functions/powers/Root.hpp"
#include "fintamath/functions/powers/Sqrt.hpp"
#include "fintamath/functions/trigonometry/Acos.hpp"
Expand Down Expand Up @@ -244,7 +244,7 @@ TEST(ParserTests, parseFunctionTest) {
EXPECT_TRUE(is<Derivative>(IFunction::parse("derivative")));
EXPECT_TRUE(is<Integral>(IFunction::parse("integral")));
EXPECT_TRUE(is<Frac>(IFunction::parse("frac")));
EXPECT_TRUE(is<PowF>(IFunction::parse("pow")));
EXPECT_TRUE(is<PowerFunction>(IFunction::parse("pow")));
EXPECT_TRUE(is<Floor>(IFunction::parse("floor")));
EXPECT_TRUE(is<Ceil>(IFunction::parse("ceil")));

Expand Down

0 comments on commit 73e6d8c

Please sign in to comment.