Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fintarin committed Jul 27, 2023
1 parent 9799ae5 commit 87270e8
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/src/literals/constants/InfTests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <gtest/gtest.h>

#include "fintamath/literals/constants/Inf.hpp"
#include "fintamath/literals/constants/Pi.hpp"

using namespace fintamath;

const Inf c;

TEST(InfTests, toStringTest) {
EXPECT_EQ(c.toString(), "Inf");
}

TEST(InfTests, callTest) {
EXPECT_EQ(c()->toString(), "Inf");
}

TEST(InfTests, equalsTest) {
EXPECT_EQ(c, c);
EXPECT_EQ(c, Inf());
EXPECT_EQ(Inf(), c);
EXPECT_EQ(c, cast<IMathObject>(Inf()));
EXPECT_EQ(cast<IMathObject>(Inf()), c);
EXPECT_NE(c, Pi());
EXPECT_NE(Pi(), c);
}

TEST(InfTests, getTypeIdTest) {
EXPECT_EQ(Inf::getTypeIdStatic(), MathObjectTypeId(MathObjectType::Inf));
EXPECT_EQ(Inf().getTypeId(), MathObjectTypeId(MathObjectType::Inf));
}
31 changes: 31 additions & 0 deletions tests/src/literals/constants/NegInfTests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <gtest/gtest.h>

#include "fintamath/literals/constants/NegInf.hpp"
#include "fintamath/literals/constants/Pi.hpp"

using namespace fintamath;

const NegInf c;

TEST(NegInfTests, toStringTest) {
EXPECT_EQ(c.toString(), "-Inf");
}

TEST(NegInfTests, callTest) {
EXPECT_EQ(c()->toString(), "-Inf");
}

TEST(NegInfTests, equalsTest) {
EXPECT_EQ(c, c);
EXPECT_EQ(c, NegInf());
EXPECT_EQ(NegInf(), c);
EXPECT_EQ(c, cast<IMathObject>(NegInf()));
EXPECT_EQ(cast<IMathObject>(NegInf()), c);
EXPECT_NE(c, Pi());
EXPECT_NE(Pi(), c);
}

TEST(NegInfTests, getTypeIdTest) {
EXPECT_EQ(NegInf::getTypeIdStatic(), MathObjectTypeId(MathObjectType::NegInf));
EXPECT_EQ(NegInf().getTypeId(), MathObjectTypeId(MathObjectType::NegInf));
}
31 changes: 31 additions & 0 deletions tests/src/literals/constants/UndefinedTests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <gtest/gtest.h>

#include "fintamath/literals/constants/Pi.hpp"
#include "fintamath/literals/constants/Undefined.hpp"

using namespace fintamath;

const Undefined c;

TEST(UndefinedTests, toStringTest) {
EXPECT_EQ(c.toString(), "Undefined");
}

TEST(UndefinedTests, callTest) {
EXPECT_EQ(c()->toString(), "Undefined");
}

TEST(UndefinedTests, equalsTest) {
EXPECT_EQ(c, c);
EXPECT_EQ(c, Undefined());
EXPECT_EQ(Undefined(), c);
EXPECT_EQ(c, cast<IMathObject>(Undefined()));
EXPECT_EQ(cast<IMathObject>(Undefined()), c);
EXPECT_NE(c, Pi());
EXPECT_NE(Pi(), c);
}

TEST(UndefinedTests, getTypeIdTest) {
EXPECT_EQ(Undefined::getTypeIdStatic(), MathObjectTypeId(MathObjectType::Undefined));
EXPECT_EQ(Undefined().getTypeId(), MathObjectTypeId(MathObjectType::Undefined));
}

0 comments on commit 87270e8

Please sign in to comment.