diff --git a/include/fintamath/core/IArithmetic.hpp b/include/fintamath/core/IArithmetic.hpp index 7d5375a48..fa86386cc 100644 --- a/include/fintamath/core/IArithmetic.hpp +++ b/include/fintamath/core/IArithmetic.hpp @@ -5,10 +5,13 @@ #include #include +#include + #include "fintamath/core/IMathObject.hpp" #include "fintamath/core/MathObjectClass.hpp" #include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/Parser.hpp" +#include "fintamath/exceptions/InvalidInputException.hpp" namespace fintamath { diff --git a/include/fintamath/core/IArithmeticCRTP.hpp b/include/fintamath/core/IArithmeticCRTP.hpp index 92331d981..7a0fa91b4 100644 --- a/include/fintamath/core/IArithmeticCRTP.hpp +++ b/include/fintamath/core/IArithmeticCRTP.hpp @@ -137,7 +137,13 @@ class IArithmeticCRTP_ : public IArithmetic { return cast(res->toMinimalObject()); } - throw InvalidInputBinaryOperatorException(operStr, toString(), rhs.toString()); + throw InvalidInputException(fmt::format( + R"(Invalid arguments of the {} operator ({} "{}" and {} "{}" are unconvertible to each other))", + operStr, + this->getClass()->getName(), + this->toString(), + rhs.getClass()->getName(), + rhs.toString())); } private: diff --git a/include/fintamath/core/IComparable.hpp b/include/fintamath/core/IComparable.hpp index 8a630f8bd..dfe3a0c6f 100644 --- a/include/fintamath/core/IComparable.hpp +++ b/include/fintamath/core/IComparable.hpp @@ -6,6 +6,8 @@ #include #include +#include + #include "fintamath/core/IArithmetic.hpp" #include "fintamath/core/MathObjectClass.hpp" #include "fintamath/core/MathObjectUtils.hpp" diff --git a/include/fintamath/core/IComparableCRTP.hpp b/include/fintamath/core/IComparableCRTP.hpp index 2f04164da..98a0dfb4e 100644 --- a/include/fintamath/core/IComparableCRTP.hpp +++ b/include/fintamath/core/IComparableCRTP.hpp @@ -34,7 +34,12 @@ class IComparableCRTP_ : public IComparable { return 0 <=> (rhs <=> *this); } - throw InvalidInputBinaryOperatorException("<=>", toString(), rhs.toString()); + throw InvalidInputException(fmt::format( + R"(Invalid arguments of the comparison operator ({} "{}" and {} "{}" are unconvertible to each other))", + this->getClass()->getName(), + this->toString(), + rhs.getClass()->getName(), + rhs.toString())); } private: diff --git a/include/fintamath/exceptions/Exception.hpp b/include/fintamath/exceptions/Exception.hpp index 9605e835e..6609db4bc 100644 --- a/include/fintamath/exceptions/Exception.hpp +++ b/include/fintamath/exceptions/Exception.hpp @@ -1,14 +1,21 @@ #pragma once #include +#include +#include namespace fintamath { class Exception : public std::exception { public: + explicit Exception(std::string inMessage) noexcept : message(std::move(inMessage)) {} + const char *what() const noexcept override { - return "Something went wrong..."; + return message.data(); } + +private: + std::string message; }; } diff --git a/include/fintamath/exceptions/InvalidInputException.hpp b/include/fintamath/exceptions/InvalidInputException.hpp index 2fb93e578..f847775fe 100644 --- a/include/fintamath/exceptions/InvalidInputException.hpp +++ b/include/fintamath/exceptions/InvalidInputException.hpp @@ -2,6 +2,7 @@ #include #include +#include #include #include "fintamath/exceptions/Exception.hpp" @@ -10,48 +11,26 @@ namespace fintamath { class InvalidInputException : public Exception { public: - InvalidInputException() noexcept = default; - - explicit InvalidInputException(const std::string &input) noexcept { - content += ": " + input; - } - - const char *what() const noexcept override { - return content.c_str(); - } - -protected: - std::string content = "Invalid input"; + explicit InvalidInputException(std::string inMessage) noexcept : Exception(std::move(inMessage)) {} }; +// TODO! remove class InvalidInputFunctionException final : public InvalidInputException { public: - explicit InvalidInputFunctionException(const std::string &func, const std::vector &argVect) noexcept { - content += ": " + func + "("; - - if (!argVect.empty()) { - for (const auto &arg : argVect) { - content += arg + ','; - } - - content.pop_back(); - } - - content += ")"; - } - - const char *what() const noexcept override { - return content.c_str(); + explicit InvalidInputFunctionException(const std::string &func, const std::vector &) noexcept + : InvalidInputException(func) { } }; +// TODO! remove class InvalidInputBinaryOperatorException final : public InvalidInputException { public: - explicit InvalidInputBinaryOperatorException(const std::string &oper, const std::string &lhs, const std::string &rhs) noexcept { - content += ": (" + lhs + ")" + oper + "(" + rhs + ")"; + explicit InvalidInputBinaryOperatorException(const std::string &oper, const std::string &, const std::string &) noexcept + : InvalidInputException(oper) { } }; +// TODO! remove class InvalidInputUnaryOperatorException final : public InvalidInputException { public: enum class Type : uint8_t { @@ -60,15 +39,8 @@ class InvalidInputUnaryOperatorException final : public InvalidInputException { }; public: - explicit InvalidInputUnaryOperatorException(const std::string &oper, const std::string &rhs, const Type type) noexcept { - switch (type) { - case Type::Prefix: - content += ": " + oper + "(" + rhs + ")"; - break; - case Type::Postfix: - content += ": (" + rhs + ")" + oper; - break; - } + explicit InvalidInputUnaryOperatorException(const std::string &oper, const std::string &, const Type) noexcept + : InvalidInputException(oper) { } }; diff --git a/include/fintamath/exceptions/UndefinedException.hpp b/include/fintamath/exceptions/UndefinedException.hpp index 213fb16ea..f92417aa3 100644 --- a/include/fintamath/exceptions/UndefinedException.hpp +++ b/include/fintamath/exceptions/UndefinedException.hpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include "fintamath/exceptions/Exception.hpp" @@ -10,48 +10,26 @@ namespace fintamath { class UndefinedException : public Exception { public: - UndefinedException() noexcept = default; - - explicit UndefinedException(const std::string &input) noexcept { - content += ": " + input; - } - - const char *what() const noexcept override { - return content.c_str(); - } - -protected: - std::string content = "Undefined"; + explicit UndefinedException(std::string inMessage) noexcept : Exception(std::move(inMessage)) {} }; +// TODO! remove class UndefinedFunctionException final : public UndefinedException { public: - explicit UndefinedFunctionException(const std::string &func, const std::vector &argVect) noexcept { - content += ": " + func + "("; - - if (!argVect.empty()) { - for (const auto &arg : argVect) { - content += arg + ','; - } - - content.pop_back(); - } - - content += ")"; - } - - const char *what() const noexcept override { - return content.c_str(); + explicit UndefinedFunctionException(const std::string &func, const std::vector &) noexcept + : UndefinedException(func) { } }; +// TODO! remove class UndefinedBinaryOperatorException final : public UndefinedException { public: - explicit UndefinedBinaryOperatorException(const std::string &oper, const std::string &lhs, const std::string &rhs) noexcept { - content += ": (" + lhs + ")" + oper + "(" + rhs + ")"; + explicit UndefinedBinaryOperatorException(const std::string &oper, const std::string &, const std::string &) noexcept + : UndefinedException(oper) { } }; +// TODO! remove class UndefinedUnaryOperatorException final : public UndefinedException { public: enum class Type : uint8_t { @@ -60,15 +38,8 @@ class UndefinedUnaryOperatorException final : public UndefinedException { }; public: - explicit UndefinedUnaryOperatorException(const std::string &oper, const std::string &rhs, const Type type) noexcept { - switch (type) { - case Type::Prefix: - content += ": " + oper + "(" + rhs + ")"; - break; - case Type::Postfix: - content += ": (" + rhs + ")" + oper; - break; - } + explicit UndefinedUnaryOperatorException(const std::string &oper, const std::string &, const Type) noexcept + : UndefinedException(oper) { } }; diff --git a/include/fintamath/literals/Boolean.hpp b/include/fintamath/literals/Boolean.hpp index 41bb81c78..45cb1023a 100644 --- a/include/fintamath/literals/Boolean.hpp +++ b/include/fintamath/literals/Boolean.hpp @@ -13,18 +13,17 @@ class Boolean : public ILiteralCRTP { public: Boolean(); - explicit Boolean(const std::string &str); - template Bool> - Boolean(const Bool val) : name(val ? trueStr : falseStr) { - } + Boolean(const Bool rhs) : val(rhs) {} + + explicit Boolean(std::string_view str); std::string toString() const override; explicit operator bool() const; private: - std::string name; + bool val; static constexpr std::string_view trueStr = "True"; diff --git a/include/fintamath/literals/Variable.hpp b/include/fintamath/literals/Variable.hpp index 9fbfa4dd1..7c7f1c503 100644 --- a/include/fintamath/literals/Variable.hpp +++ b/include/fintamath/literals/Variable.hpp @@ -12,9 +12,9 @@ class Variable : public ILiteralCRTP { FINTAMATH_CLASS_BODY(Variable, ILiteral) public: - explicit Variable(std::string inName); + explicit Variable(std::string_view inName); - explicit Variable(std::string inName, Integer inIndex); + explicit Variable(std::string_view inName, Integer inIndex); std::string toString() const override; diff --git a/include/fintamath/numbers/Integer.hpp b/include/fintamath/numbers/Integer.hpp index 22767819e..5a78aff68 100644 --- a/include/fintamath/numbers/Integer.hpp +++ b/include/fintamath/numbers/Integer.hpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -29,7 +30,7 @@ class Integer : public INumberCRTP { Integer(Backend inBackend); - explicit Integer(std::string str); + explicit Integer(std::string_view str); std::string toString() const override; diff --git a/include/fintamath/numbers/Rational.hpp b/include/fintamath/numbers/Rational.hpp index a90b69155..b0e678466 100644 --- a/include/fintamath/numbers/Rational.hpp +++ b/include/fintamath/numbers/Rational.hpp @@ -26,7 +26,7 @@ class Rational : public INumberCRTP { explicit Rational(Integer inNumer, Integer inDenom); - explicit Rational(const std::string &str); + explicit Rational(std::string_view str); std::string toString() const override; diff --git a/include/fintamath/numbers/Real.hpp b/include/fintamath/numbers/Real.hpp index 9f5905627..41a0ef0ed 100644 --- a/include/fintamath/numbers/Real.hpp +++ b/include/fintamath/numbers/Real.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -51,7 +52,7 @@ class Real : public INumberCRTP { Real(const Integer &rhs); - explicit Real(std::string str); + explicit Real(std::string_view str); std::string toString() const override; diff --git a/src/fintamath/expressions/Expression.cpp b/src/fintamath/expressions/Expression.cpp index f9416cb70..44ba06f68 100644 --- a/src/fintamath/expressions/Expression.cpp +++ b/src/fintamath/expressions/Expression.cpp @@ -8,9 +8,12 @@ #include #include #include +#include #include #include +#include + #include "fintamath/core/Cache.hpp" #include "fintamath/core/IMathObject.hpp" #include "fintamath/core/MathObjectClass.hpp" @@ -93,7 +96,7 @@ const ArgumentPtrVector &Expression::getChildren() const { void Expression::setChildren(const ArgumentPtrVector &childVect) { if (childVect.size() != 1) { - throw InvalidInputFunctionException("", argumentVectorToStringVector(childVect)); + throw InvalidInputFunctionException("...", argumentVectorToStringVector(childVect)); } *this = Expression(childVect.front()); @@ -138,9 +141,9 @@ std::unique_ptr parseExpr(const std::string &str) { try { auto tokens = Tokenizer::tokenize(str); auto terms = Expression::tokensToTerms(tokens); - auto stack = Expression::termsToOperands(terms); - auto obj = Expression::operandsToObject(stack); - return obj; + auto operands = Expression::termsToOperands(terms); + auto object = Expression::operandsToObject(operands); + return object; } catch (const InvalidInputException &) { throw InvalidInputException(str); @@ -149,7 +152,7 @@ std::unique_ptr parseExpr(const std::string &str) { TermVector Expression::tokensToTerms(TokenVector &tokens) { if (tokens.empty()) { - throw InvalidInputException(""); + throw InvalidInputException("..."); } TermVector terms(tokens.size()); @@ -180,13 +183,13 @@ OperandStack Expression::termsToOperands(TermVector &terms) { moveFunctionTermsToOperands(operands, functions, {}); if (functions.empty()) { - throw InvalidInputException(""); + throw InvalidInputException("..."); } functions.pop(); } else { - throw InvalidInputException(""); + throw InvalidInputException("..."); } } else if (is(term.value)) { @@ -207,7 +210,7 @@ OperandStack Expression::termsToOperands(TermVector &terms) { moveFunctionTermsToOperands(operands, functions, {}); if (!functions.empty()) { - throw InvalidInputException(""); + throw InvalidInputException("..."); } return operands; @@ -215,7 +218,7 @@ OperandStack Expression::termsToOperands(TermVector &terms) { std::unique_ptr Expression::operandsToObject(OperandStack &operands) { if (operands.empty()) { - throw InvalidInputException(""); + throw InvalidInputException("..."); } std::unique_ptr arg = std::move(operands.top()); @@ -236,7 +239,7 @@ std::unique_ptr Expression::operandsToObject(OperandStack &operands func = parseFunction(func->toString(), children.size()); if (!func) { - throw InvalidInputException(""); + throw InvalidInputException("..."); } } @@ -334,7 +337,7 @@ void Expression::fixOperatorTypes(TermVector &terms) { } if (!isFixed) { - throw InvalidInputException(""); + throw InvalidInputException("..."); } if (terms.size() < 3) { @@ -368,7 +371,7 @@ void Expression::fixOperatorTypes(TermVector &terms) { } if (!isFixed) { - throw InvalidInputException(""); + throw InvalidInputException("..."); } } @@ -453,20 +456,39 @@ Expression::ExpressionMaker &Expression::getExpressionMaker() { void Expression::validateFunctionArgs(const IFunction &func, const ArgumentPtrVector &args) { const ArgumentTypeVector &expectedArgTypes = func.getArgumentClasses(); - if (args.empty() || (!func.isVariadic() && args.size() != expectedArgTypes.size())) { - throw InvalidInputFunctionException(func.toString(), argumentVectorToStringVector(args)); + if (args.size() != expectedArgTypes.size()) { + if (!func.isVariadic()) { + throw InvalidInputException(fmt::format( + R"(Unable to call {} with {} argument{} (expected {}))", + func.getClass()->getName(), + args.size(), + args.size() != 1 ? "s" : "", + func.getArgumentClasses().size())); + } + + if (args.empty()) { + throw InvalidInputException(fmt::format( + R"(Unable to call {} with 0 arguments (expected > 0))", + func.getClass()->getName())); + } } const bool doesArgSizeMatch = !func.isVariadic() && args.size() == expectedArgTypes.size(); - MathObjectClass expectedType = expectedArgTypes.front(); + MathObjectClass expectedClass = expectedArgTypes.front(); for (size_t i = 0; i < args.size(); i++) { if (doesArgSizeMatch) { - expectedType = expectedArgTypes[i]; + expectedClass = expectedArgTypes[i]; } - if (const ArgumentPtr &arg = args[i]; !doesArgMatch(expectedType, arg)) { - throw InvalidInputFunctionException(func.toString(), argumentVectorToStringVector(args)); + if (const ArgumentPtr &arg = args[i]; !doesArgMatch(expectedClass, arg)) { + throw InvalidInputException(fmt::format( + R"(Unable to call {} with argument #{} {} "{}" (expected {}))", + func.getClass()->getName(), + i, + arg->getClass()->getName(), + arg->toString(), + expectedClass->getName())); } } } diff --git a/src/fintamath/expressions/FunctionExpression.cpp b/src/fintamath/expressions/FunctionExpression.cpp index 8736acab1..599c88139 100644 --- a/src/fintamath/expressions/FunctionExpression.cpp +++ b/src/fintamath/expressions/FunctionExpression.cpp @@ -79,9 +79,7 @@ ArgumentPtr FunctionExpression::simplifyRec(bool isPostSimplify) const { } void FunctionExpression::setChildren(const ArgumentPtrVector &childVect) { - if (childVect.size() != func->getArgumentClasses().size()) { - throw InvalidInputFunctionException(func->toString(), argumentVectorToStringVector(childVect)); - } + (void)makeExpr(*func, childVect); children = childVect; } diff --git a/src/fintamath/expressions/interfaces/IBinaryExpression.cpp b/src/fintamath/expressions/interfaces/IBinaryExpression.cpp index 64333a0ef..1157ea05b 100644 --- a/src/fintamath/expressions/interfaces/IBinaryExpression.cpp +++ b/src/fintamath/expressions/interfaces/IBinaryExpression.cpp @@ -98,9 +98,7 @@ IBinaryExpression::SimplifyFunctionVector IBinaryExpression::getFunctionsForPost } void IBinaryExpression::setChildren(const ArgumentPtrVector &childVect) { - if (childVect.size() != 2) { - throw InvalidInputFunctionException(toString(), argumentVectorToStringVector(childVect)); - } + (void)makeExpr(*func, childVect); lhsChild = childVect[0]; rhsChild = childVect[1]; diff --git a/src/fintamath/expressions/interfaces/IPolynomExpression.cpp b/src/fintamath/expressions/interfaces/IPolynomExpression.cpp index 9a7b48cf7..0df3b042f 100644 --- a/src/fintamath/expressions/interfaces/IPolynomExpression.cpp +++ b/src/fintamath/expressions/interfaces/IPolynomExpression.cpp @@ -40,9 +40,7 @@ const ArgumentPtrVector &IPolynomExpression::getChildren() const { } void IPolynomExpression::setChildren(const ArgumentPtrVector &childVect) { - if (childVect.empty()) { - throw InvalidInputFunctionException(toString(), {}); - } + (void)makeExpr(*func, childVect); children = childVect; } diff --git a/src/fintamath/expressions/interfaces/IUnaryExpression.cpp b/src/fintamath/expressions/interfaces/IUnaryExpression.cpp index e8a12afcc..3b28593a2 100644 --- a/src/fintamath/expressions/interfaces/IUnaryExpression.cpp +++ b/src/fintamath/expressions/interfaces/IUnaryExpression.cpp @@ -96,9 +96,7 @@ ArgumentPtr IUnaryExpression::simplifyRec(const bool isPostSimplify) const { } void IUnaryExpression::setChildren(const ArgumentPtrVector &childVect) { - if (childVect.size() != 1) { - throw InvalidInputFunctionException(toString(), argumentVectorToStringVector(childVect)); - } + (void)makeExpr(*func, childVect); child = childVect.front(); } diff --git a/src/fintamath/functions/IFunction.cpp b/src/fintamath/functions/IFunction.cpp index 4ada3680b..2ae2f63c1 100644 --- a/src/fintamath/functions/IFunction.cpp +++ b/src/fintamath/functions/IFunction.cpp @@ -1,9 +1,8 @@ #include "fintamath/functions/IFunction.hpp" -#include -#include -#include +#include +#include "fintamath/exceptions/InvalidInputException.hpp" #include "fintamath/functions/FunctionArguments.hpp" namespace fintamath { diff --git a/src/fintamath/functions/other/Comma.cpp b/src/fintamath/functions/other/Comma.cpp index 5c277c80e..9c93c372b 100644 --- a/src/fintamath/functions/other/Comma.cpp +++ b/src/fintamath/functions/other/Comma.cpp @@ -2,6 +2,8 @@ #include +#include + #include "fintamath/core/IMathObject.hpp" #include "fintamath/functions/FunctionArguments.hpp" @@ -9,11 +11,10 @@ namespace fintamath { FINTAMATH_CLASS_IMPLEMENTATION(Comma) -std::unique_ptr Comma::call(const ArgumentRefVector &argVect) const { - const auto &lhs = argVect.front().get(); - const auto &rhs = argVect.back().get(); - - throw InvalidInputBinaryOperatorException(toString(), lhs.toString(), rhs.toString()); +std::unique_ptr Comma::call(const ArgumentRefVector & /*argVect*/) const { + throw InvalidInputException(fmt::format( + R"(Calling {} directly is not allowed)", + getClassStatic()->getName())); } } diff --git a/src/fintamath/literals/Boolean.cpp b/src/fintamath/literals/Boolean.cpp index 3b4869cc3..e9b7ff32f 100644 --- a/src/fintamath/literals/Boolean.cpp +++ b/src/fintamath/literals/Boolean.cpp @@ -1,28 +1,35 @@ #include "fintamath/literals/Boolean.hpp" +#include + +#include + #include "fintamath/exceptions/InvalidInputException.hpp" namespace fintamath { FINTAMATH_CLASS_IMPLEMENTATION(Boolean) -Boolean::Boolean() : name(falseStr) { +Boolean::Boolean() : val(false) { } -Boolean::Boolean(const std::string &str) { +Boolean::Boolean(const std::string_view str) { if (str != trueStr && str != falseStr) { - throw InvalidInputException(str); + throw InvalidInputException(fmt::format( + R"(Unable to parse {} from "{}" (expected "True" or "False"))", + getClassStatic()->getName(), + str)); } - name = str; + val = str == trueStr; } std::string Boolean::toString() const { - return name; + return val ? std::string(trueStr) : std::string(falseStr); } Boolean::operator bool() const { - return name == trueStr; + return val; } } diff --git a/src/fintamath/literals/Variable.cpp b/src/fintamath/literals/Variable.cpp index 4de6f9071..3ef599a29 100644 --- a/src/fintamath/literals/Variable.cpp +++ b/src/fintamath/literals/Variable.cpp @@ -1,8 +1,11 @@ #include "fintamath/literals/Variable.hpp" #include +#include #include +#include + #include "fintamath/exceptions/InvalidInputException.hpp" #include "fintamath/numbers/Integer.hpp" @@ -10,28 +13,31 @@ namespace fintamath { FINTAMATH_CLASS_IMPLEMENTATION(Variable) -Variable::Variable(std::string inName) { - if (inName.size() != 1) { - throw InvalidInputException(inName); - } - - if (const char ch = inName.front(); ch < 'a' || ch > 'z') { - throw InvalidInputException(inName); +Variable::Variable(std::string_view inName) { + if (inName.size() != 1 || inName.front() < 'a' || inName.front() > 'z') { + throw InvalidInputException(fmt::format( + R"(Unable to parse {} name from "{}" (expected single English lowercase letter))", + getClassStatic()->getName(), + inName)); } - name = std::move(inName); + name = std::string(inName); } -Variable::Variable(std::string inName, Integer inIndex) : Variable(std::move(inName)) { +Variable::Variable(std::string_view inName, Integer inIndex) : Variable(inName) { if (inIndex < 0) { - throw InvalidInputException(name + "_" + inIndex.toString()); + throw InvalidInputException(fmt::format( + R"(Negative {} index "{}" is not allowed)", + getClassStatic()->getName(), + inIndex.toString())); } index = std::move(inIndex); } std::string Variable::toString() const { - return name + (index != -1 ? "_" + index.toString() : ""); + std::string indexStr = index != -1 ? fmt::format("_{}", index.toString()) : ""; + return fmt::format("{}{}", name, indexStr); } } diff --git a/src/fintamath/numbers/Complex.cpp b/src/fintamath/numbers/Complex.cpp index ddc4a3d2f..8d223b52b 100644 --- a/src/fintamath/numbers/Complex.cpp +++ b/src/fintamath/numbers/Complex.cpp @@ -5,6 +5,8 @@ #include #include +#include + #include "fintamath/core/Converter.hpp" #include "fintamath/core/IMathObject.hpp" #include "fintamath/core/MathObjectUtils.hpp" @@ -31,17 +33,15 @@ Complex &Complex::operator=(const Complex &rhs) { return *this; } -Complex::Complex(const std::string &str) { - if (!str.empty() && str.back() == 'I') { - im = parseNonComplexNumber(str.substr(0, str.size() - 1)); - } - else { - re = parseNonComplexNumber(str); +Complex::Complex(const INumber &inRe, const INumber &inIm) { + if (is(inRe) || is(inIm)) { + throw InvalidInputException(fmt::format( + R"(Nested {} numbers are not allowed)", + getClassStatic()->getName())); } - if (!re || !im) { - throw InvalidInputException(str); - } + re = cast(inRe.toMinimalObject()); + im = cast(inIm.toMinimalObject()); } Complex::Complex(const Integer &rhs) : re(cast(rhs.toMinimalObject())) { @@ -53,13 +53,23 @@ Complex::Complex(const Rational &rhs) : re(cast(rhs.toMinimalObject())) Complex::Complex(const Real &rhs) : re(cast(rhs.toMinimalObject())) { } -Complex::Complex(const INumber &inReal, const INumber &inImag) { - if (is(inReal) || is(inImag)) { - throw InvalidInputException("Nested complex numbers are not allowed"); +Complex::Complex(const std::string &str) try { + if (!str.empty() && str.back() == 'I') { + im = parseNonComplexNumber(str.substr(0, str.size() - 1)); + } + else { + re = parseNonComplexNumber(str); } - re = cast(inReal.toMinimalObject()); - im = cast(inImag.toMinimalObject()); + if (!re || !im) { + throw InvalidInputException("Invalid input"); + } +} +catch (const InvalidInputException &) { + throw InvalidInputException(fmt::format( + R"(Unable to parse {} from "{}")", + getClassStatic()->getName(), + str)); } std::string Complex::toString() const { @@ -187,7 +197,10 @@ Complex &Complex::divide(const Complex &rhs) { im = *(*(y * u) - *(x * v)) / *divisor; } catch (const UndefinedException &) { - throw UndefinedBinaryOperatorException("/", toString(), rhs.toString()); + throw UndefinedException(fmt::format( + R"(Undefined "{}" / "{}" (division by zero))", + toString(), + rhs.toString())); } return *this; diff --git a/src/fintamath/numbers/Integer.cpp b/src/fintamath/numbers/Integer.cpp index d095e3537..52f635052 100644 --- a/src/fintamath/numbers/Integer.cpp +++ b/src/fintamath/numbers/Integer.cpp @@ -4,8 +4,11 @@ #include #include #include +#include #include +#include + #include "fintamath/exceptions/InvalidInputException.hpp" #include "fintamath/exceptions/UndefinedException.hpp" #include "fintamath/numbers/NumberUtils.hpp" @@ -19,20 +22,24 @@ using namespace detail; Integer::Integer(Backend inBackend) : backend(std::move(inBackend)) { } -Integer::Integer(std::string str) { +Integer::Integer(const std::string_view str) try { if (str.empty()) { - throw InvalidInputException(str); + throw InvalidInputException("Invalid input"); } - str = removeLeadingZeroes(std::move(str)); - try { - backend.assign(str); + backend.assign(removeLeadingZeroes(std::string(str))); } catch (const std::runtime_error &) { - throw InvalidInputException(str); + throw InvalidInputException("Invalid input"); } } +catch (const InvalidInputException &) { + throw InvalidInputException(fmt::format( + R"(Unable to parse {} from "{}")", + getClassStatic()->getName(), + str)); +} std::string Integer::toString() const { return backend.str(); @@ -71,7 +78,10 @@ Integer &Integer::multiply(const Integer &rhs) { Integer &Integer::divide(const Integer &rhs) { if (rhs == 0) { - throw UndefinedBinaryOperatorException("/", toString(), rhs.toString()); + throw UndefinedException(fmt::format( + R"(Undefined "{}" / "{}" (division by zero))", + toString(), + rhs.toString())); } backend /= rhs.backend; @@ -85,7 +95,10 @@ Integer &Integer::negate() { Integer &Integer::mod(const Integer &rhs) { if (rhs == 0) { - throw UndefinedBinaryOperatorException("mod", toString(), rhs.toString()); + throw UndefinedException(fmt::format( + R"(Undefined "{}" % "{}" (modulo by zero))", + toString(), + rhs.toString())); } backend %= rhs.backend; @@ -108,23 +121,27 @@ Integer &Integer::bitXor(const Integer &rhs) { } Integer &Integer::bitLeftShift(const Integer &rhs) { - try { - backend <<= static_cast(rhs.backend); - return *this; - } - catch (...) { - throw UndefinedBinaryOperatorException("<<", toString(), rhs.toString()); + if (rhs < 0) { + throw UndefinedException(fmt::format( + R"(Undefined "{}" << "{}" (negative shift))", + toString(), + rhs.toString())); } + + backend <<= static_cast(rhs.backend); + return *this; } Integer &Integer::bitRightShift(const Integer &rhs) { - try { - backend >>= static_cast(rhs.backend); - return *this; - } - catch (...) { - throw UndefinedBinaryOperatorException(">>", toString(), rhs.toString()); + if (rhs < 0) { + throw UndefinedException(fmt::format( + R"(Undefined "{}" >> "{}" (negative shift))", + toString(), + rhs.toString())); } + + backend >>= static_cast(rhs.backend); + return *this; } Integer &Integer::bitNot() { diff --git a/src/fintamath/numbers/NumberAbstract.cpp b/src/fintamath/numbers/NumberAbstract.cpp index bb48f1413..df5cf4655 100644 --- a/src/fintamath/numbers/NumberAbstract.cpp +++ b/src/fintamath/numbers/NumberAbstract.cpp @@ -27,9 +27,7 @@ std::unique_ptr Integer::divideAbstract(const IArithmetic &rhs) con } if (const auto *intRhs = cast(&rhs)) { - if (*this % *intRhs != 0) { - return cast(Rational(*this, *intRhs).clone()); - } + return cast(Rational(*this, *intRhs).toMinimalObject()); } return INumberCRTP::divideAbstract(rhs); diff --git a/src/fintamath/numbers/NumberUtils.cpp b/src/fintamath/numbers/NumberUtils.cpp index d83cc19a1..1c9784d48 100644 --- a/src/fintamath/numbers/NumberUtils.cpp +++ b/src/fintamath/numbers/NumberUtils.cpp @@ -1,5 +1,6 @@ #include "fintamath/numbers/NumberUtils.hpp" +#include #include #include @@ -13,7 +14,7 @@ std::string removeLeadingZeroes(std::string str) { const size_t firstNonZeroDigit = str.find_first_not_of('0', firstDigit); - if (firstNonZeroDigit == std::string::npos) { + if (firstNonZeroDigit == std::string::npos || !std::isdigit(str[firstNonZeroDigit])) { str.insert(firstDigit, "0"); } else if (firstNonZeroDigit > firstDigit) { diff --git a/src/fintamath/numbers/Rational.cpp b/src/fintamath/numbers/Rational.cpp index c7ce3ecf3..16bf828a7 100644 --- a/src/fintamath/numbers/Rational.cpp +++ b/src/fintamath/numbers/Rational.cpp @@ -7,8 +7,11 @@ #include #include #include +#include #include +#include + #include "fintamath/core/IMathObject.hpp" #include "fintamath/exceptions/InvalidInputException.hpp" #include "fintamath/exceptions/UndefinedException.hpp" @@ -26,16 +29,23 @@ Rational::Rational(Integer inNumer, Integer inDenom) : numer(std::move(inNumer)), denom(std::move(inDenom)) { + if (denom == 0) { + throw UndefinedException(fmt::format( + R"(Undefined "{}" / "{}" (division by zero))", + numer.toString(), + denom.toString())); + } + toIrreducibleRational(); } -Rational::Rational(const std::string &str) { +Rational::Rational(const std::string_view str) try { if (str.empty()) { - throw InvalidInputException(str); + throw InvalidInputException("Invalid input"); } if (str.empty() || str == ".") { - throw InvalidInputException(str); + throw InvalidInputException("Invalid input"); } int64_t firstDigitNum = 0; @@ -47,8 +57,8 @@ Rational::Rational(const std::string &str) { firstDigitNum++; } - const std::string intPartStr = str.substr(static_cast(firstDigitNum), - static_cast(firstDotNum - firstDigitNum)); + const std::string intPartStr(str.substr(static_cast(firstDigitNum), + static_cast(firstDotNum - firstDigitNum))); Integer intPart; if (!intPartStr.empty()) { @@ -57,7 +67,7 @@ Rational::Rational(const std::string &str) { } if (firstDotNum + 1 < std::ssize(str)) { - const std::string numeratorStr = str.substr(static_cast(firstDotNum) + 1); + const std::string numeratorStr(str.substr(static_cast(firstDotNum) + 1)); std::string denominatorStr(numeratorStr.size() + 1, '0'); denominatorStr.front() = '1'; numer = Integer(numeratorStr); @@ -65,7 +75,7 @@ Rational::Rational(const std::string &str) { } if (intPart < 0 || numer < 0) { - throw InvalidInputException(str); + throw InvalidInputException("Invalid input"); } toIrreducibleRational(); @@ -75,13 +85,11 @@ Rational::Rational(const std::string &str) { numer *= -1; } } - -const Integer &Rational::numerator() const noexcept { - return numer; -} - -const Integer &Rational::denominator() const noexcept { - return denom; +catch (const InvalidInputException &) { + throw InvalidInputException(fmt::format( + R"(Unable to parse {} from "{}")", + getClassStatic()->getName(), + str)); } std::string Rational::toString() const { @@ -105,6 +113,14 @@ int Rational::sign() const { return numer.sign(); } +const Integer &Rational::numerator() const noexcept { + return numer; +} + +const Integer &Rational::denominator() const noexcept { + return denom; +} + bool Rational::equals(const Rational &rhs) const { return numer == rhs.numer && denom == rhs.denom; } @@ -140,6 +156,13 @@ Rational &Rational::multiply(const Rational &rhs) { } Rational &Rational::divide(const Rational &rhs) { + if (rhs == 0) { + throw UndefinedException(fmt::format( + R"(Undefined "{}" / "{}" (division by zero))", + toString(), + rhs.toString())); + } + numer *= rhs.denom; denom *= rhs.numer; toIrreducibleRational(); @@ -152,10 +175,6 @@ Rational &Rational::negate() { } void Rational::toIrreducibleRational() { - if (denom == 0) { - throw UndefinedBinaryOperatorException("/", numer.toString(), denom.toString()); - } - if (denom < 0) { numer *= -1; denom *= -1; diff --git a/src/fintamath/numbers/Real.cpp b/src/fintamath/numbers/Real.cpp index 6955105ba..94bcddf2f 100644 --- a/src/fintamath/numbers/Real.cpp +++ b/src/fintamath/numbers/Real.cpp @@ -8,10 +8,13 @@ #include #include #include +#include #include #include +#include + #include "fintamath/exceptions/InvalidInputException.hpp" #include "fintamath/exceptions/UndefinedException.hpp" #include "fintamath/numbers/Integer.hpp" @@ -31,48 +34,58 @@ Real::Real(Backend inBackend) : backend(std::move(inBackend)), isNegative(backend < 0) { if (!isFinite()) { - throw UndefinedException(backend.str()); + throw UndefinedException(fmt::format( + R"(Undefined {})", + toString())); } } -Real::Real(std::string str) : Real() { +Real::Real(const Rational &rhs) + : Real(Real(rhs.numerator()) / Real(rhs.denominator())) {} + +Real::Real(const Integer &rhs) + : backend(rhs.getBackend()), + isNegative(rhs < 0) {} + +Real::Real(const std::string_view str) try : Real() { if (str.empty() || str == ".") { - throw InvalidInputException(str); + throw InvalidInputException("Invalid input"); } - str = removeLeadingZeroes(std::move(str)); + std::string mutableStr = removeLeadingZeroes(std::string(str)); - if (str.front() == '-') { + if (mutableStr.front() == '-') { isNegative = true; } { const std::string expStr = "*10^"; - const size_t expPos = str.find(expStr); + const size_t expPos = mutableStr.find(expStr); if (expPos != std::string::npos) { - str.replace(expPos, expStr.length(), "e"); + mutableStr.replace(expPos, expStr.length(), "e"); } } try { - backend.assign(str); + backend.assign(mutableStr); } catch (const std::runtime_error &) { - throw InvalidInputException(str); + throw InvalidInputException("Invalid input"); } if (!isFinite()) { - throw UndefinedException(str); + throw UndefinedException(fmt::format( + R"(Undefined "{}" (overflow))", + str)); } } - -Real::Real(const Rational &rhs) - : Real(Real(rhs.numerator()) / Real(rhs.denominator())) {} - -Real::Real(const Integer &rhs) - : backend(rhs.getBackend()), - isNegative(rhs < 0) {} +catch (const InvalidInputException &) { + throw InvalidInputException(fmt::format( + R"(Unable to parse {} from "{}")", + getClassStatic()->getName(), + str)); +} std::string Real::toString() const { std::string res = toString(outputPrecision); @@ -220,15 +233,18 @@ Real &Real::multiply(const Real &rhs) { } Real &Real::divide(const Real &rhs) { + if (rhs == 0) { + throw UndefinedException(fmt::format( + R"(Undefined "{}" / "{}" (division by zero))", + toString(), + rhs.toString())); + } + updatePrecision(rhs); isNegative = isNegative != rhs.isNegative; backend /= rhs.backend; - if (!isFinite()) { - throw UndefinedBinaryOperatorException("/", toString(), rhs.toString()); - } - return *this; } diff --git a/src/fintamath/numbers/RealFunctions.cpp b/src/fintamath/numbers/RealFunctions.cpp index f978b009e..e7f986018 100644 --- a/src/fintamath/numbers/RealFunctions.cpp +++ b/src/fintamath/numbers/RealFunctions.cpp @@ -43,7 +43,7 @@ bool isLogUnderflow(const Real &rhs) { const Real &trigResultChecked(const Real &rhs) { if (isUnderflow(rhs) || isOverflow(rhs)) { - throw UndefinedException(""); + throw UndefinedException("..."); } return rhs; @@ -51,7 +51,7 @@ const Real &trigResultChecked(const Real &rhs) { const Real &hyperbResultChecked(const Real &rhs) { if (isUnderflow(rhs)) { - throw UndefinedException(""); + throw UndefinedException("..."); } return rhs; @@ -59,7 +59,7 @@ const Real &hyperbResultChecked(const Real &rhs) { const Real &tgammaResultChecked(const Real &rhs) { if (rhs == 0) { - throw UndefinedException(""); + throw UndefinedException("..."); } return rhs; diff --git a/tests/src/core/IArithmeticTests.cpp b/tests/src/core/IArithmeticTests.cpp index 092501e6f..35928e802 100644 --- a/tests/src/core/IArithmeticTests.cpp +++ b/tests/src/core/IArithmeticTests.cpp @@ -1,3 +1,4 @@ +#include #include #include "fintamath/core/IArithmetic.hpp" @@ -76,8 +77,14 @@ TEST(IArithmeticTests, addTest) { EXPECT_TRUE(is(*m3 + *m2)); EXPECT_TRUE(is(*m3 + *m3)); - EXPECT_THROW(*m1 + TestArithmetic(), InvalidInputBinaryOperatorException); - EXPECT_THROW(TestArithmetic() + *m1, InvalidInputBinaryOperatorException); + EXPECT_THAT( + [&] { *m1 + TestArithmetic(); }, + testing::ThrowsMessage( + testing::StrEq(R"(Invalid arguments of the + operator (Integer "1" and TestArithmetic "TestArithmetic" are unconvertible to each other))"))); + EXPECT_THAT( + [&] { TestArithmetic() + *m1; }, + testing::ThrowsMessage( + testing::StrEq(R"(Invalid arguments of the + operator (TestArithmetic "TestArithmetic" and Integer "1" are unconvertible to each other))"))); Integer a; EXPECT_EQ((a += 3).toString(), "3"); @@ -112,8 +119,14 @@ TEST(IArithmeticTests, subTest) { EXPECT_TRUE(is(*m3 - *m2)); EXPECT_TRUE(is(*m3 - *m3)); - EXPECT_THROW(*m1 - TestArithmetic(), InvalidInputBinaryOperatorException); - EXPECT_THROW(TestArithmetic() - *m1, InvalidInputBinaryOperatorException); + EXPECT_THAT( + [&] { *m1 - TestArithmetic(); }, + testing::ThrowsMessage( + testing::StrEq(R"(Invalid arguments of the - operator (Integer "1" and TestArithmetic "TestArithmetic" are unconvertible to each other))"))); + EXPECT_THAT( + [&] { TestArithmetic() - *m1; }, + testing::ThrowsMessage( + testing::StrEq(R"(Invalid arguments of the - operator (TestArithmetic "TestArithmetic" and Integer "1" are unconvertible to each other))"))); Integer a; EXPECT_EQ((a -= 3).toString(), "-3"); @@ -148,8 +161,14 @@ TEST(IArithmeticTests, mulTest) { EXPECT_TRUE(is(*m3 * *m2)); EXPECT_TRUE(is(*m3 * *m3)); - EXPECT_THROW(*m1 * TestArithmetic(), InvalidInputBinaryOperatorException); - EXPECT_THROW(TestArithmetic() * *m1, InvalidInputBinaryOperatorException); + EXPECT_THAT( + [&] { *m1 * TestArithmetic(); }, + testing::ThrowsMessage( + testing::StrEq(R"(Invalid arguments of the * operator (Integer "1" and TestArithmetic "TestArithmetic" are unconvertible to each other))"))); + EXPECT_THAT( + [&] { TestArithmetic() * *m1; }, + testing::ThrowsMessage( + testing::StrEq(R"(Invalid arguments of the * operator (TestArithmetic "TestArithmetic" and Integer "1" are unconvertible to each other))"))); Integer a = 2; EXPECT_EQ((a *= 3).toString(), "6"); @@ -184,8 +203,14 @@ TEST(IArithmeticTests, divTest) { EXPECT_TRUE(is(*m3 / *m2)); EXPECT_TRUE(is(*m3 / *m3)); - EXPECT_THROW(*m1 / TestArithmetic(), InvalidInputBinaryOperatorException); - EXPECT_THROW(TestArithmetic() / *m1, InvalidInputBinaryOperatorException); + EXPECT_THAT( + [&] { *m1 / TestArithmetic(); }, + testing::ThrowsMessage( + testing::StrEq(R"(Invalid arguments of the / operator (Integer "1" and TestArithmetic "TestArithmetic" are unconvertible to each other))"))); + EXPECT_THAT( + [&] { TestArithmetic() / *m1; }, + testing::ThrowsMessage( + testing::StrEq(R"(Invalid arguments of the / operator (TestArithmetic "TestArithmetic" and Integer "1" are unconvertible to each other))"))); Integer a = 4; EXPECT_EQ((a /= 2).toString(), "2"); diff --git a/tests/src/core/IComparableTests.cpp b/tests/src/core/IComparableTests.cpp index 5631f136e..bce3f6c07 100644 --- a/tests/src/core/IComparableTests.cpp +++ b/tests/src/core/IComparableTests.cpp @@ -1,3 +1,4 @@ +#include #include #include "fintamath/core/IComparable.hpp" @@ -67,8 +68,14 @@ TEST(IComparableTests, lessTest) { EXPECT_TRUE(*m3 < *m1); EXPECT_TRUE(*m3 < *m2); - EXPECT_THROW((void)(*m1 < TestComparable()), InvalidInputBinaryOperatorException); - EXPECT_THROW(void(TestComparable() < *m1), InvalidInputBinaryOperatorException); + EXPECT_THAT( + [&] { *m1 < TestComparable(); }, + testing::ThrowsMessage( + testing::StrEq(R"(Invalid arguments of the comparison operator (Integer "1" and TestComparable "TestComparable" are unconvertible to each other))"))); + EXPECT_THAT( + [&] { TestComparable() < *m1; }, + testing::ThrowsMessage( + testing::StrEq(R"(Invalid arguments of the comparison operator (TestComparable "TestComparable" and Integer "1" are unconvertible to each other))"))); EXPECT_TRUE(Integer() < 1); EXPECT_TRUE(-1 < Integer()); @@ -92,8 +99,14 @@ TEST(IComparableTests, moreTest) { EXPECT_FALSE(*m3 > *m1); EXPECT_FALSE(*m3 > *m2); - EXPECT_THROW(void(*m1 > TestComparable()), InvalidInputBinaryOperatorException); - EXPECT_THROW(void(TestComparable() > *m1), InvalidInputBinaryOperatorException); + EXPECT_THAT( + [&] { *m1 < TestComparable(); }, + testing::ThrowsMessage( + testing::StrEq(R"(Invalid arguments of the comparison operator (Integer "1" and TestComparable "TestComparable" are unconvertible to each other))"))); + EXPECT_THAT( + [&] { TestComparable() < *m1; }, + testing::ThrowsMessage( + testing::StrEq(R"(Invalid arguments of the comparison operator (TestComparable "TestComparable" and Integer "1" are unconvertible to each other))"))); EXPECT_FALSE(Integer() > 1); EXPECT_FALSE(-1 > Integer()); @@ -117,8 +130,14 @@ TEST(IComparableTests, lessEqualsTest) { EXPECT_TRUE(*m3 <= *m1); EXPECT_TRUE(*m3 <= *m2); - EXPECT_THROW(void(*m1 <= TestComparable()), InvalidInputBinaryOperatorException); - EXPECT_THROW(void(TestComparable() <= *m1), InvalidInputBinaryOperatorException); + EXPECT_THAT( + [&] { *m1 <= TestComparable(); }, + testing::ThrowsMessage( + testing::StrEq(R"(Invalid arguments of the comparison operator (Integer "1" and TestComparable "TestComparable" are unconvertible to each other))"))); + EXPECT_THAT( + [&] { TestComparable() <= *m1; }, + testing::ThrowsMessage( + testing::StrEq(R"(Invalid arguments of the comparison operator (TestComparable "TestComparable" and Integer "1" are unconvertible to each other))"))); EXPECT_TRUE(Integer() <= 1); EXPECT_TRUE(-1 <= Integer()); @@ -142,8 +161,14 @@ TEST(IComparableTests, moreEqualsTest) { EXPECT_FALSE(*m3 >= *m1); EXPECT_FALSE(*m3 >= *m2); - EXPECT_THROW(void(*m1 >= TestComparable()), InvalidInputBinaryOperatorException); - EXPECT_THROW(void(TestComparable() >= *m1), InvalidInputBinaryOperatorException); + EXPECT_THAT( + [&] { *m1 >= TestComparable(); }, + testing::ThrowsMessage( + testing::StrEq(R"(Invalid arguments of the comparison operator (Integer "1" and TestComparable "TestComparable" are unconvertible to each other))"))); + EXPECT_THAT( + [&] { TestComparable() >= *m1; }, + testing::ThrowsMessage( + testing::StrEq(R"(Invalid arguments of the comparison operator (TestComparable "TestComparable" and Integer "1" are unconvertible to each other))"))); EXPECT_FALSE(Integer() >= 1); EXPECT_FALSE(-1 >= Integer()); diff --git a/tests/src/exceptions/ExceptionTests.cpp b/tests/src/exceptions/ExceptionTests.cpp index 45a99b1df..f867013fa 100644 --- a/tests/src/exceptions/ExceptionTests.cpp +++ b/tests/src/exceptions/ExceptionTests.cpp @@ -7,7 +7,7 @@ using namespace fintamath; TEST(ExceptionTests, whatTest) { EXPECT_THAT( - [] { throw Exception(); }, + [] { throw Exception("Unknown exception"); }, testing::ThrowsMessage( - testing::StrEq("Something went wrong..."))); + testing::StrEq("Unknown exception"))); } diff --git a/tests/src/exceptions/InvalidInputBinaryOperatorExceptionTests.cpp b/tests/src/exceptions/InvalidInputBinaryOperatorExceptionTests.cpp deleted file mode 100644 index 0cc84d94f..000000000 --- a/tests/src/exceptions/InvalidInputBinaryOperatorExceptionTests.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include - -#include "fintamath/exceptions/InvalidInputException.hpp" - -using namespace fintamath; - -TEST(InvalidInputBinaryOpearatorExceptionTests, whatTest) { - EXPECT_THAT( - [] { throw InvalidInputBinaryOperatorException("^", "a", "0"); }, - testing::ThrowsMessage( - testing::StrEq("Invalid input: (a)^(0)"))); -} diff --git a/tests/src/exceptions/InvalidInputExceptionTests.cpp b/tests/src/exceptions/InvalidInputExceptionTests.cpp index aca858578..ffb10d1f7 100644 --- a/tests/src/exceptions/InvalidInputExceptionTests.cpp +++ b/tests/src/exceptions/InvalidInputExceptionTests.cpp @@ -7,11 +7,7 @@ using namespace fintamath; TEST(InvalidInputExceptionTests, whatTest) { EXPECT_THAT( - [] { throw InvalidInputException(); }, + [] { throw InvalidInputException("Invalid input"); }, testing::ThrowsMessage( testing::StrEq("Invalid input"))); - EXPECT_THAT( - [] { throw InvalidInputException("123"); }, - testing::ThrowsMessage( - testing::StrEq("Invalid input: 123"))); -} \ No newline at end of file +} diff --git a/tests/src/exceptions/InvalidInputFunctionExceptionTests.cpp b/tests/src/exceptions/InvalidInputFunctionExceptionTests.cpp deleted file mode 100644 index 65416c397..000000000 --- a/tests/src/exceptions/InvalidInputFunctionExceptionTests.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -#include "fintamath/exceptions/InvalidInputException.hpp" - -using namespace fintamath; - -TEST(InvalidInputFunctionExceptionTests, whatTest) { - EXPECT_THAT( - [] { throw InvalidInputFunctionException("f", {}); }, - testing::ThrowsMessage( - testing::StrEq("Invalid input: f()"))); - EXPECT_THAT( - [] { throw InvalidInputFunctionException("sqrt", {"-10", "a", "b"}); }, - testing::ThrowsMessage( - testing::StrEq("Invalid input: sqrt(-10,a,b)"))); -} diff --git a/tests/src/exceptions/InvalidInputUnaryOperatorExceptionTests.cpp b/tests/src/exceptions/InvalidInputUnaryOperatorExceptionTests.cpp deleted file mode 100644 index 2c1403984..000000000 --- a/tests/src/exceptions/InvalidInputUnaryOperatorExceptionTests.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -#include "fintamath/exceptions/InvalidInputException.hpp" - -using namespace fintamath; - -TEST(InvalidInputUnaryOpearatorExceptionTests, whatTest) { - EXPECT_THAT( - [] { throw InvalidInputUnaryOperatorException("!", "-10", InvalidInputUnaryOperatorException::Type::Prefix); }, - testing::ThrowsMessage( - testing::StrEq("Invalid input: !(-10)"))); - EXPECT_THAT( - [] { throw InvalidInputUnaryOperatorException("!", "-10", InvalidInputUnaryOperatorException::Type::Postfix); }, - testing::ThrowsMessage( - testing::StrEq("Invalid input: (-10)!"))); -} diff --git a/tests/src/exceptions/UndefinedBinaryOperatorExceptionTests.cpp b/tests/src/exceptions/UndefinedBinaryOperatorExceptionTests.cpp deleted file mode 100644 index bd751dc64..000000000 --- a/tests/src/exceptions/UndefinedBinaryOperatorExceptionTests.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include - -#include "fintamath/exceptions/UndefinedException.hpp" - -using namespace fintamath; - -TEST(UndefinedBinaryOpearatorExceptionTests, whatTest) { - EXPECT_THAT( - [] { throw UndefinedBinaryOperatorException("^", "a", "0"); }, - testing::ThrowsMessage( - testing::StrEq("Undefined: (a)^(0)"))); -} diff --git a/tests/src/exceptions/UndefinedExceptionTests.cpp b/tests/src/exceptions/UndefinedExceptionTests.cpp index 59bd52967..2c3add660 100644 --- a/tests/src/exceptions/UndefinedExceptionTests.cpp +++ b/tests/src/exceptions/UndefinedExceptionTests.cpp @@ -7,11 +7,7 @@ using namespace fintamath; TEST(UndefinedExceptionTests, whatTest) { EXPECT_THAT( - [] { throw UndefinedException(); }, + [] { throw UndefinedException("Undefined"); }, testing::ThrowsMessage( testing::StrEq("Undefined"))); - EXPECT_THAT( - [] { throw UndefinedException("123"); }, - testing::ThrowsMessage( - testing::StrEq("Undefined: 123"))); -} \ No newline at end of file +} diff --git a/tests/src/exceptions/UndefinedFunctionExceptionTests.cpp b/tests/src/exceptions/UndefinedFunctionExceptionTests.cpp deleted file mode 100644 index 101edc757..000000000 --- a/tests/src/exceptions/UndefinedFunctionExceptionTests.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -#include "fintamath/exceptions/UndefinedException.hpp" - -using namespace fintamath; - -TEST(UndefinedFunctionExceptionTests, whatTest) { - EXPECT_THAT( - [] { throw UndefinedFunctionException("f", {}); }, - testing::ThrowsMessage( - testing::StrEq("Undefined: f()"))); - EXPECT_THAT( - [] { throw UndefinedFunctionException("sqrt", {"-10", "a", "b"}); }, - testing::ThrowsMessage( - testing::StrEq("Undefined: sqrt(-10,a,b)"))); -} diff --git a/tests/src/exceptions/UndefinedUnaryOperatorExceptionTests.cpp b/tests/src/exceptions/UndefinedUnaryOperatorExceptionTests.cpp deleted file mode 100644 index 297f3e5e7..000000000 --- a/tests/src/exceptions/UndefinedUnaryOperatorExceptionTests.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -#include "fintamath/exceptions/UndefinedException.hpp" - -using namespace fintamath; - -TEST(UndefinedUnaryOpearatorExceptionTests, whatTest) { - EXPECT_THAT( - [] { throw UndefinedUnaryOperatorException("!", "-10", UndefinedUnaryOperatorException::Type::Prefix); }, - testing::ThrowsMessage( - testing::StrEq("Undefined: !(-10)"))); - EXPECT_THAT( - [] { throw UndefinedUnaryOperatorException("!", "-10", UndefinedUnaryOperatorException::Type::Postfix); }, - testing::ThrowsMessage( - testing::StrEq("Undefined: (-10)!"))); -} diff --git a/tests/src/expressions/ExpressionFunctionsTests.cpp b/tests/src/expressions/ExpressionFunctionsTests.cpp index fee472f95..e9cc8e836 100644 --- a/tests/src/expressions/ExpressionFunctionsTests.cpp +++ b/tests/src/expressions/ExpressionFunctionsTests.cpp @@ -1,3 +1,4 @@ +#include #include #include "fintamath/expressions/ExpressionFunctions.hpp" @@ -333,9 +334,24 @@ TEST(ExpressionFunctionsTests, complexInfTest) { } TEST(ExpressionFunctionsTests, negativeTest) { - EXPECT_THROW(Boolean(true) + Boolean(false), InvalidInputException); - EXPECT_THROW(Add() / Mul(), InvalidInputException); - EXPECT_THROW(sin(Boolean(true)), InvalidInputException); - EXPECT_THROW(eqv(Boolean(true), Boolean(false)), InvalidInputException); - EXPECT_THROW(orL(Integer(1), Integer(2)), InvalidInputException); + EXPECT_THAT( + [&] { Boolean(true) + Boolean(false); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Add with argument #0 Boolean "True" (expected IArithmetic))"))); + EXPECT_THAT( + [&] { Add() / Mul(); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Div with argument #0 Add "add" (expected IArithmetic))"))); + EXPECT_THAT( + [&] { sin(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Sin with argument #0 Boolean "True" (expected INumber))"))); + EXPECT_THAT( + [&] { eqv(Boolean(true), Boolean(false)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Eqv with argument #0 Boolean "True" (expected IComparable))"))); + EXPECT_THAT( + [&] { orL(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Or with argument #0 Integer "1" (expected Boolean))"))); } diff --git a/tests/src/expressions/ExpressionParserTests.cpp b/tests/src/expressions/ExpressionParserTests.cpp index 8957645c3..619d68813 100644 --- a/tests/src/expressions/ExpressionParserTests.cpp +++ b/tests/src/expressions/ExpressionParserTests.cpp @@ -1,3 +1,4 @@ +#include #include #include "fintamath/expressions/ExpressionParser.hpp" @@ -37,120 +38,450 @@ TEST(ExpressionParserTests, parseExprTest) { } TEST(ExpressionParserTests, parseExprNegativeTest) { - EXPECT_THROW(parseExpr(""), InvalidInputException); - EXPECT_THROW(parseExpr("1+"), InvalidInputException); - EXPECT_THROW(parseExpr("1-"), InvalidInputException); - EXPECT_THROW(parseExpr("1*"), InvalidInputException); - EXPECT_THROW(parseExpr("1/"), InvalidInputException); - EXPECT_THROW(parseExpr("*1"), InvalidInputException); - EXPECT_THROW(parseExpr("/1"), InvalidInputException); - EXPECT_THROW(parseExpr(" + "), InvalidInputException); - EXPECT_THROW(parseExpr("(1+2))"), InvalidInputException); - EXPECT_THROW(parseExpr("5-*3"), InvalidInputException); - EXPECT_THROW(parseExpr("5 3 +"), InvalidInputException); - EXPECT_THROW(parseExpr("2.2.2"), InvalidInputException); - EXPECT_THROW(parseExpr("--"), InvalidInputException); - EXPECT_THROW(parseExpr("."), InvalidInputException); - EXPECT_THROW(parseExpr(","), InvalidInputException); - EXPECT_THROW(parseExpr("/"), InvalidInputException); - EXPECT_THROW(parseExpr(";"), InvalidInputException); - EXPECT_THROW(parseExpr("\'"), InvalidInputException); - EXPECT_THROW(parseExpr("["), InvalidInputException); - EXPECT_THROW(parseExpr("]"), InvalidInputException); - EXPECT_THROW(parseExpr("!"), InvalidInputException); - EXPECT_THROW(parseExpr("@"), InvalidInputException); - EXPECT_THROW(parseExpr("\""), InvalidInputException); - EXPECT_THROW(parseExpr("#"), InvalidInputException); - EXPECT_THROW(parseExpr("№"), InvalidInputException); - EXPECT_THROW(parseExpr("%"), InvalidInputException); - EXPECT_THROW(parseExpr(":"), InvalidInputException); - EXPECT_THROW(parseExpr("?"), InvalidInputException); - EXPECT_THROW(parseExpr("*"), InvalidInputException); - EXPECT_THROW(parseExpr("("), InvalidInputException); - EXPECT_THROW(parseExpr(")"), InvalidInputException); - EXPECT_THROW(parseExpr("-"), InvalidInputException); - EXPECT_THROW(parseExpr("+"), InvalidInputException); - EXPECT_THROW(parseExpr("$"), InvalidInputException); - EXPECT_THROW(parseExpr("^"), InvalidInputException); - EXPECT_THROW(parseExpr("&"), InvalidInputException); - EXPECT_THROW(parseExpr("_"), InvalidInputException); - EXPECT_THROW(parseExpr("[1+1]"), InvalidInputException); - EXPECT_THROW(parseExpr("{1}"), InvalidInputException); - EXPECT_THROW(parseExpr(",2"), InvalidInputException); - EXPECT_THROW(parseExpr("2,"), InvalidInputException); + EXPECT_THAT( + [] { parseExpr(""); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("1+"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("1-"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("1*"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("1/"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("*1"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("/1"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr(" + "); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("(1+2))"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("5-*3"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("5 3 +"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("2.2.2"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("--"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("."); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr(","); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("/"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr(";"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("\'"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("["); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("]"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("!"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("@"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("\""); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("#"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("№"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("%"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr(":"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("?"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("*"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("("); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr(")"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("-"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("+"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("$"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("^"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("&"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("_"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("[1+1]"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("{1}"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr(",2"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("2,"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); - EXPECT_THROW(parseExpr("(1"), InvalidInputException); - EXPECT_THROW(parseExpr("(((2)"), InvalidInputException); - EXPECT_THROW(parseExpr("(((2))"), InvalidInputException); - EXPECT_THROW(parseExpr("((2)))"), InvalidInputException); - EXPECT_THROW(parseExpr("(2)))"), InvalidInputException); - EXPECT_THROW(parseExpr("(2"), InvalidInputException); - EXPECT_THROW(parseExpr("((2)"), InvalidInputException); - EXPECT_THROW(parseExpr("((2"), InvalidInputException); - EXPECT_THROW(parseExpr("((((2)((2))))"), InvalidInputException); - EXPECT_THROW(parseExpr("(()())"), InvalidInputException); - EXPECT_THROW(parseExpr("((()()))"), InvalidInputException); - EXPECT_THROW(parseExpr("((((()))))"), InvalidInputException); - EXPECT_THROW(parseExpr("(,) + (,)"), InvalidInputException); + EXPECT_THAT( + [] { parseExpr("(1"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("(((2)"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("(((2))"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("((2)))"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("(2)))"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("(2"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("((2)"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("((2"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("((((2)((2))))"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("(()())"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("((()()))"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("((((()))))"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("(,) + (,)"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); - EXPECT_THROW(parseExpr("!2"), InvalidInputException); - EXPECT_THROW(parseExpr("!!2"), InvalidInputException); - EXPECT_THROW(parseExpr("!2!!"), InvalidInputException); - EXPECT_THROW(parseExpr("!(2"), InvalidInputException); - EXPECT_THROW(parseExpr("!(2)"), InvalidInputException); - EXPECT_THROW(parseExpr("2)!"), InvalidInputException); - EXPECT_THROW(parseExpr("sin(2))!"), InvalidInputException); - EXPECT_THROW(parseExpr("!!!!!!"), InvalidInputException); + EXPECT_THAT( + [] { parseExpr("!2"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("!!2"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("!2!!"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("!(2"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("!(2)"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("2)!"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("sin(2))!"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("!!!!!!"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); - EXPECT_THROW(parseExpr("esin()"), InvalidInputException); - EXPECT_THROW(parseExpr("(a+b)*()"), InvalidInputException); + EXPECT_THAT( + [] { parseExpr("esin()"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("(a+b)*()"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); - EXPECT_THROW(parseExpr("sin(2,3)"), InvalidInputException); - EXPECT_THROW(parseExpr("sin(2,3) + 2"), InvalidInputException); - EXPECT_THROW(parseExpr("cos(sin(2,3))"), InvalidInputException); - EXPECT_THROW(parseExpr("sin(,)"), InvalidInputException); - EXPECT_THROW(parseExpr("sin(,2)"), InvalidInputException); - EXPECT_THROW(parseExpr("sin(2,)"), InvalidInputException); - EXPECT_THROW(parseExpr("sin()"), InvalidInputException); - EXPECT_THROW(parseExpr("log(1)"), InvalidInputException); - EXPECT_THROW(parseExpr("log()"), InvalidInputException); + EXPECT_THAT( + [] { parseExpr("sin(2,3)"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("sin(2,3) + 2"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("cos(sin(2,3))"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("sin(,)"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("sin(,2)"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("sin(2,)"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("sin()"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("log(1)"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("log()"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); - EXPECT_THROW(parseExpr("(1 = 1) / 2"), InvalidInputException); - EXPECT_THROW(parseExpr("2 + (1 = 2)"), InvalidInputException); - EXPECT_THROW(parseExpr("sin(1 = 1)"), InvalidInputException); - EXPECT_THROW(parseExpr("sin(sin(1 = 1))"), InvalidInputException); - EXPECT_THROW(parseExpr("sin(sin(sin(1 = 1)))"), InvalidInputException); - EXPECT_THROW(parseExpr("True/True"), InvalidInputException); - EXPECT_THROW(parseExpr("((1 == 1)) + ((1 == 2))"), InvalidInputException); - EXPECT_THROW(parseExpr("((1 == 1)) - ((1 == 1))"), InvalidInputException); - EXPECT_THROW(parseExpr("((1 == 1)) / ((1 == 1))"), InvalidInputException); - EXPECT_THROW(parseExpr("(5+5)=(2=5)"), InvalidInputException); - EXPECT_THROW(parseExpr("1+(sin(x)<2)"), InvalidInputException); - EXPECT_THROW(parseExpr("1/(sin(x)<2)"), InvalidInputException); - EXPECT_THROW(parseExpr("1+False"), InvalidInputException); - EXPECT_THROW(parseExpr("False+1"), InvalidInputException); - EXPECT_THROW(parseExpr("1=False"), InvalidInputException); - EXPECT_THROW(parseExpr("False=1"), InvalidInputException); - EXPECT_THROW(parseExpr("1&2"), InvalidInputException); - EXPECT_THROW(parseExpr("x+1&x+2"), InvalidInputException); - EXPECT_THROW(parseExpr("x+1&x"), InvalidInputException); - EXPECT_THROW(parseExpr("x&x+2"), InvalidInputException); - EXPECT_THROW(parseExpr("(x&y)=(y&z)"), InvalidInputException); - EXPECT_THROW(parseExpr("derivative(x=y, x)"), InvalidInputException); - EXPECT_THROW(parseExpr("derivative(x&y,x)"), InvalidInputException); - EXPECT_THROW(parseExpr("derivative(True,a)"), InvalidInputException); - EXPECT_THROW(parseExpr("(a+1)_(a>2)"), InvalidInputException); - EXPECT_THROW(parseExpr("(x+1)_1"), InvalidInputException); - EXPECT_THROW(parseExpr("(x*2)_1"), InvalidInputException); - EXPECT_THROW(parseExpr("(x*2)_((x+2)_x)"), InvalidInputException); - EXPECT_THROW(parseExpr("x^x_1"), InvalidInputException); - EXPECT_THROW(parseExpr("E&a"), InvalidInputException); - EXPECT_THROW(parseExpr("~Inf"), InvalidInputException); - EXPECT_THROW(parseExpr("~Undefined"), InvalidInputException); - EXPECT_THROW(parseExpr("a | Undefined"), InvalidInputException); + EXPECT_THAT( + [] { parseExpr("(1 = 1) / 2"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("2 + (1 = 2)"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("sin(1 = 1)"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("sin(sin(1 = 1))"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("sin(sin(sin(1 = 1)))"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("True/True"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("((1 == 1)) + ((1 == 2))"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("((1 == 1)) - ((1 == 1))"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("((1 == 1)) / ((1 == 1))"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("(5+5)=(2=5)"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("1+(sin(x)<2)"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("1/(sin(x)<2)"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("1+False"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("False+1"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("1=False"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("False=1"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("1&2"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("x+1&x+2"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("x+1&x"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("x&x+2"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("(x&y)=(y&z)"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("derivative(x=y, x)"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("derivative(x&y,x)"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("derivative(True,a)"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("(a+1)_(a>2)"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("(x+1)_1"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("(x*2)_1"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("(x*2)_((x+2)_x)"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("x^x_1"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("E&a"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("~Inf"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("~Undefined"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("a | Undefined"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); - EXPECT_THROW(parseExpr("min()"), InvalidInputException); - EXPECT_THROW(parseExpr("min(True, False)"), InvalidInputException); - EXPECT_THROW(parseExpr("max()"), InvalidInputException); - EXPECT_THROW(parseExpr("max(True, False)"), InvalidInputException); + EXPECT_THAT( + [] { parseExpr("min()"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("min(True, False)"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("max()"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { parseExpr("max(True, False)"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); } diff --git a/tests/src/expressions/ExpressionTests.cpp b/tests/src/expressions/ExpressionTests.cpp index e3a083b0f..8463d0325 100644 --- a/tests/src/expressions/ExpressionTests.cpp +++ b/tests/src/expressions/ExpressionTests.cpp @@ -1,3 +1,4 @@ +#include #include #include "fintamath/expressions/Expression.hpp" @@ -36,8 +37,14 @@ TEST(ExpressionTests, stringConstructorTest) { } TEST(ExpressionTests, stringConstructorNegativeTest) { - EXPECT_THROW(Expression(""), InvalidInputException); - EXPECT_THROW(Expression("1+"), InvalidInputException); + EXPECT_THAT( + [] { Expression(""); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { Expression("1+"); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); } TEST(ExpressionTests, setChildrenTest) { @@ -49,7 +56,10 @@ TEST(ExpressionTests, setChildrenTest) { expr.setChildren({Expression("a-a").clone()}); EXPECT_EQ(expr.toString(), "0"); - EXPECT_THROW(expr.setChildren({Variable("a").clone(), Variable("b").clone()}), InvalidInputException); + EXPECT_THAT( + [&] { expr.setChildren({Variable("a").clone(), Variable("b").clone()}); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); } TEST(ExpressionTests, getFunctionTest) { diff --git a/tests/src/expressions/IExpressionTests.cpp b/tests/src/expressions/IExpressionTests.cpp index 528160b08..3c42398d7 100644 --- a/tests/src/expressions/IExpressionTests.cpp +++ b/tests/src/expressions/IExpressionTests.cpp @@ -80,8 +80,6 @@ TEST(IExpressionTests, setChildrenTest) { expr->setChildren({Variable("b").clone()}); EXPECT_EQ(expr->toString(), "b!"); - EXPECT_THROW(expr->setChildren({Variable("b").clone(), Variable("c").clone()}), InvalidInputException); - // TODO: implement more tests } diff --git a/tests/src/expressions/interfaces/IBinaryExpressionTests.cpp b/tests/src/expressions/interfaces/IBinaryExpressionTests.cpp index 69cac65ee..13af5031a 100644 --- a/tests/src/expressions/interfaces/IBinaryExpressionTests.cpp +++ b/tests/src/expressions/interfaces/IBinaryExpressionTests.cpp @@ -1,3 +1,4 @@ +#include #include #include "fintamath/expressions/interfaces/IBinaryExpression.hpp" @@ -42,14 +43,14 @@ TEST(IBinaryExpressionTests, getFunctionTest) { EXPECT_EQ(*expr.getFunction(), f); } -TEST(IBinaryExpressionTests, getChildren) { +TEST(IBinaryExpressionTests, getChildrenTest) { const TestBinaryExpression expr(std::make_shared(1), std::make_shared(2)); EXPECT_EQ(expr.getChildren().size(), 2); EXPECT_EQ(*expr.getChildren().front(), Integer(1)); EXPECT_EQ(*expr.getChildren().back(), Integer(2)); } -TEST(IBinaryExpressionTests, setChildren) { +TEST(IBinaryExpressionTests, setChildrenTest) { TestBinaryExpression expr(std::make_shared(1), std::make_shared(2)); expr.setChildren({std::make_shared(0), std::make_shared(0)}); @@ -57,11 +58,18 @@ TEST(IBinaryExpressionTests, setChildren) { EXPECT_EQ(*expr.getChildren().front(), Integer(0)); EXPECT_EQ(*expr.getChildren().back(), Integer(0)); - EXPECT_THROW(expr.setChildren({}), InvalidInputFunctionException); - EXPECT_THROW(expr.setChildren({std::make_shared(1)}), InvalidInputFunctionException); - EXPECT_THROW( - expr.setChildren({std::make_shared(1), std::make_shared(1), std::make_shared(1)}), - InvalidInputFunctionException); + EXPECT_THAT( + [&] { expr.setChildren({}); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call AddOper with 0 arguments (expected 2)"))); + EXPECT_THAT( + [&] { expr.setChildren({std::make_shared(1)}); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call AddOper with 1 argument (expected 2)"))); + EXPECT_THAT( + [&] { expr.setChildren({std::make_shared(1), std::make_shared(1), std::make_shared(1)}); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call AddOper with 3 arguments (expected 2)"))); } TEST(IBinaryExpressionTests, toMinimalObjectTest) { diff --git a/tests/src/expressions/interfaces/IPolynomExpressionTests.cpp b/tests/src/expressions/interfaces/IPolynomExpressionTests.cpp index afcaf8b66..2a8560859 100644 --- a/tests/src/expressions/interfaces/IPolynomExpressionTests.cpp +++ b/tests/src/expressions/interfaces/IPolynomExpressionTests.cpp @@ -1,3 +1,4 @@ +#include #include #include "fintamath/expressions/interfaces/IPolynomExpression.hpp" @@ -46,7 +47,7 @@ TEST(IPolynomExpressionTests, getFunctionTest) { EXPECT_EQ(*expr.getFunction(), f); } -TEST(IPolynomExpressionTests, getChildren) { +TEST(IPolynomExpressionTests, getChildrenTest) { const TestPolynomExpression expr({Integer(1).clone(), Integer(2).clone(), Integer(3).clone()}); EXPECT_EQ(expr.getChildren().size(), 3); EXPECT_EQ(*expr.getChildren()[0], Integer(1)); @@ -54,7 +55,7 @@ TEST(IPolynomExpressionTests, getChildren) { EXPECT_EQ(*expr.getChildren()[2], Integer(3)); } -TEST(IPolynomExpressionTests, setChildren) { +TEST(IPolynomExpressionTests, setChildrenTest) { TestPolynomExpression expr({Integer(1).clone(), Integer(2).clone(), Integer(3).clone()}); expr.setChildren({Integer(0).clone()}); @@ -72,7 +73,10 @@ TEST(IPolynomExpressionTests, setChildren) { EXPECT_EQ(*expr.getChildren()[1], Integer(0)); EXPECT_EQ(*expr.getChildren()[2], Integer(0)); - EXPECT_THROW(expr.setChildren({}), InvalidInputFunctionException); + EXPECT_THAT( + [&] { expr.setChildren({}); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Mul with 0 arguments (expected > 0)"))); } TEST(IPolynomExpressionTests, toMinimalObjectTest) { diff --git a/tests/src/expressions/interfaces/IUnaryExpressionTests.cpp b/tests/src/expressions/interfaces/IUnaryExpressionTests.cpp index 9816a017a..11a41d4cb 100644 --- a/tests/src/expressions/interfaces/IUnaryExpressionTests.cpp +++ b/tests/src/expressions/interfaces/IUnaryExpressionTests.cpp @@ -1,3 +1,4 @@ +#include #include #include "fintamath/expressions/interfaces/IUnaryExpression.hpp" @@ -42,22 +43,27 @@ TEST(IUnaryExpressionTests, getFunctionTest) { EXPECT_EQ(*expr.getFunction(), f); } -TEST(IUnaryExpressionTests, getChildren) { +TEST(IUnaryExpressionTests, getChildrenTest) { const TestUnaryExpression expr(std::make_shared(1)); EXPECT_EQ(expr.getChildren().size(), 1); EXPECT_EQ(*expr.getChildren().front(), Integer(1)); } -TEST(IUnaryExpressionTests, setChildren) { +TEST(IUnaryExpressionTests, setChildrenTest) { TestUnaryExpression expr(std::make_shared(1)); expr.setChildren({std::make_shared(0)}); EXPECT_EQ(expr.getChildren().size(), 1); EXPECT_EQ(*expr.getChildren().front(), Integer(0)); - EXPECT_THROW(expr.setChildren({}), InvalidInputFunctionException); - EXPECT_THROW(expr.setChildren({std::make_shared(1), std::make_shared(1)}), - InvalidInputFunctionException); + EXPECT_THAT( + [&] { expr.setChildren({}); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Factorial with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { expr.setChildren({std::make_shared(1), std::make_shared(1)}); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Factorial with 2 arguments (expected 1)"))); } TEST(IUnaryExpressionTests, toMinimalObjectTest) { diff --git a/tests/src/functions/FunctionUtilsTests.cpp b/tests/src/functions/FunctionUtilsTests.cpp index 9628f4914..252847035 100644 --- a/tests/src/functions/FunctionUtilsTests.cpp +++ b/tests/src/functions/FunctionUtilsTests.cpp @@ -1,3 +1,4 @@ +#include #include #include "fintamath/expressions/Expression.hpp" @@ -7,6 +8,7 @@ #include "fintamath/functions/arithmetic/Add.hpp" #include "fintamath/functions/arithmetic/MulOper.hpp" #include "fintamath/functions/powers/Pow.hpp" +#include "fintamath/functions/powers/PowOper.hpp" #include "fintamath/functions/trigonometry/Cos.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Integer.hpp" @@ -27,10 +29,22 @@ TEST(FunctionUtilsTests, makeExpressionPtrsTest) { EXPECT_EQ(expr2->toString(), "cos(a)"); EXPECT_TRUE(is(expr2)); - EXPECT_THROW(makeExpr(MulOper(), ArgumentPtrVector{var})->toString(), InvalidInputException); - EXPECT_THROW(makeExpr(MulOper(), ArgumentPtrVector{})->toString(), InvalidInputException); - EXPECT_THROW(makeExpr(MulOper(), ArgumentPtrVector{var})->toString(), InvalidInputException); - EXPECT_THROW(makeExpr(MulOper(), ArgumentPtrVector{})->toString(), InvalidInputException); + EXPECT_THAT( + [&] { makeExpr(MulOper(), ArgumentPtrVector{var}); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call MulOper with 1 argument (expected 2)"))); + EXPECT_THAT( + [] { makeExpr(MulOper(), ArgumentPtrVector{}); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call MulOper with 0 arguments (expected 2)"))); + EXPECT_THAT( + [&] { makeExpr(PowOper(), ArgumentPtrVector{var}); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call PowOper with 1 argument (expected 2)"))); + EXPECT_THAT( + [] { makeExpr(PowOper(), ArgumentPtrVector{}); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call PowOper with 0 arguments (expected 2)"))); } TEST(FunctionUtilsTests, makeExpressionRefsTest) { @@ -45,10 +59,22 @@ TEST(FunctionUtilsTests, makeExpressionRefsTest) { EXPECT_EQ(expr2->toString(), "cos(a)"); EXPECT_TRUE(is(expr2)); - EXPECT_THROW(makeExpr(MulOper(), ArgumentRefVector{var})->toString(), InvalidInputException); - EXPECT_THROW(makeExpr(MulOper(), ArgumentRefVector{})->toString(), InvalidInputException); - EXPECT_THROW(makeExpr(MulOper(), ArgumentRefVector{var})->toString(), InvalidInputException); - EXPECT_THROW(makeExpr(MulOper(), ArgumentRefVector{})->toString(), InvalidInputException); + EXPECT_THAT( + [&] { makeExpr(MulOper(), ArgumentRefVector{var}); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call MulOper with 1 argument (expected 2)"))); + EXPECT_THAT( + [] { makeExpr(MulOper(), ArgumentRefVector{}); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call MulOper with 0 arguments (expected 2)"))); + EXPECT_THAT( + [&] { makeExpr(PowOper(), ArgumentRefVector{var}); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call PowOper with 1 argument (expected 2)"))); + EXPECT_THAT( + [] { makeExpr(PowOper(), ArgumentRefVector{}); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call PowOper with 0 arguments (expected 2)"))); } TEST(FunctionUtilsTests, makeExpressionAnyArgsRefTest) { diff --git a/tests/src/functions/IFunctionTests.cpp b/tests/src/functions/IFunctionTests.cpp index 5e0a60c1b..fd690a839 100644 --- a/tests/src/functions/IFunctionTests.cpp +++ b/tests/src/functions/IFunctionTests.cpp @@ -3,11 +3,11 @@ #include "fintamath/functions/IFunction.hpp" +#include "fintamath/functions/arithmetic/Div.hpp" #include "fintamath/functions/arithmetic/Mul.hpp" #include "fintamath/functions/arithmetic/Neg.hpp" #include "fintamath/functions/arithmetic/Sub.hpp" #include "fintamath/functions/arithmetic/UnaryPlus.hpp" -#include "fintamath/functions/logarithms/Log.hpp" #include "fintamath/functions/trigonometry/Sin.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Integer.hpp" @@ -40,61 +40,51 @@ TEST(IFunctionTests, parseTest) { } TEST(IFunctionTests, callTest) { - std::unique_ptr f = std::make_unique(); + std::unique_ptr f = std::make_unique
(); Integer a = 3; Rational b(1, 2); Variable c("c"); EXPECT_EQ((*f)(a, a)->toString(), "1"); EXPECT_EQ((*f)(b, b)->toString(), "1"); - EXPECT_EQ((*f)(a, b)->toString(), "-0.6309297535714574371"); - EXPECT_EQ((*f)(b, a)->toString(), "-1.5849625007211561815"); + EXPECT_EQ((*f)(a, b)->toString(), "6"); + EXPECT_EQ((*f)(b, a)->toString(), "1/6"); - EXPECT_EQ((*f)(a, c)->toString(), "log(3, c)"); - - EXPECT_THROW((*f)(), InvalidInputFunctionException); - EXPECT_THROW((*f)(a), InvalidInputFunctionException); - EXPECT_THROW((*f)(a, a, a), InvalidInputFunctionException); - EXPECT_THROW((*f)(a, a, a, a, a, a, a), InvalidInputFunctionException); + EXPECT_EQ((*f)(a, c)->toString(), "3/c"); } TEST(IFunctionTests, callVectTest) { - std::unique_ptr f = std::make_unique(); + std::unique_ptr f = std::make_unique
(); Integer a = 3; Rational b(1, 2); Variable c("c"); EXPECT_EQ((*f)({a, a})->toString(), "1"); EXPECT_EQ((*f)({b, b})->toString(), "1"); - EXPECT_EQ((*f)({a, b})->toString(), "-0.6309297535714574371"); - EXPECT_EQ((*f)({b, a})->toString(), "-1.5849625007211561815"); - - EXPECT_EQ((*f)({a, c})->toString(), "log(3, c)"); + EXPECT_EQ((*f)({a, b})->toString(), "6"); + EXPECT_EQ((*f)({b, a})->toString(), "1/6"); - EXPECT_THROW((*f)({}), InvalidInputFunctionException); - EXPECT_THROW((*f)({a}), InvalidInputFunctionException); - EXPECT_THROW((*f)({a, a, a}), InvalidInputFunctionException); - EXPECT_THROW((*f)({a, a, a, a, a, a, a}), InvalidInputFunctionException); + EXPECT_EQ((*f)({a, c})->toString(), "3/c"); } TEST(IFunctionTests, equalsTest) { - EXPECT_EQ(Log(), Log()); - EXPECT_NE(Log(), Sub()); - EXPECT_NE(Sub(), Log()); - EXPECT_NE(Log(), UnaryPlus()); - EXPECT_NE(UnaryPlus(), Log()); - EXPECT_NE(Log(), Sin()); - EXPECT_NE(Sin(), Log()); + EXPECT_EQ(Div(), Div()); + EXPECT_NE(Div(), Sub()); + EXPECT_NE(Sub(), Div()); + EXPECT_NE(Div(), UnaryPlus()); + EXPECT_NE(UnaryPlus(), Div()); + EXPECT_NE(Div(), Sin()); + EXPECT_NE(Sin(), Div()); } TEST(IFunctionTests, getArgumentClassesTest) { - EXPECT_THAT(Log().getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic(), INumber::getClassStatic())); + EXPECT_THAT(Div().getArgumentClasses(), testing::ElementsAre(IArithmetic::getClassStatic(), IArithmetic::getClassStatic())); EXPECT_THAT(Neg().getArgumentClasses(), testing::ElementsAre(IArithmetic::getClassStatic())); EXPECT_THAT(Sin().getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } TEST(IFunctionTests, getReturnClassTest) { - EXPECT_EQ(Log().getReturnClass(), INumber::getClassStatic()); + EXPECT_EQ(Div().getReturnClass(), IArithmetic::getClassStatic()); EXPECT_EQ(Neg().getReturnClass(), IArithmetic::getClassStatic()); EXPECT_EQ(Sin().getReturnClass(), INumber::getClassStatic()); } @@ -105,15 +95,15 @@ TEST(IFunctionTests, doArgsMatchTest) { Variable c("c"); { - EXPECT_TRUE(Log().doArgsMatch({a, b})); - EXPECT_FALSE(Log().doArgsMatch({c, c})); - EXPECT_FALSE(Log().doArgsMatch({a, c})); - EXPECT_FALSE(Log().doArgsMatch({c, a})); - - EXPECT_FALSE(Log().doArgsMatch({})); - EXPECT_FALSE(Log().doArgsMatch({a})); - EXPECT_FALSE(Log().doArgsMatch({a, a, a})); - EXPECT_FALSE(Log().doArgsMatch({a, b, a, b})); + EXPECT_TRUE(Div().doArgsMatch({a, b})); + EXPECT_FALSE(Div().doArgsMatch({c, c})); + EXPECT_FALSE(Div().doArgsMatch({a, c})); + EXPECT_FALSE(Div().doArgsMatch({c, a})); + + EXPECT_FALSE(Div().doArgsMatch({})); + EXPECT_FALSE(Div().doArgsMatch({a})); + EXPECT_FALSE(Div().doArgsMatch({a, a, a})); + EXPECT_FALSE(Div().doArgsMatch({a, b, a, b})); } { EXPECT_TRUE(Mul().doArgsMatch({a, b, a})); diff --git a/tests/src/functions/arithmetic/AbsTests.cpp b/tests/src/functions/arithmetic/AbsTests.cpp index b1a6159a4..253ddf902 100644 --- a/tests/src/functions/arithmetic/AbsTests.cpp +++ b/tests/src/functions/arithmetic/AbsTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/arithmetic/Abs.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -60,8 +61,27 @@ TEST(AbsTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "abs(a)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Abs with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Abs with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Abs with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Abs with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Abs with 4 arguments (expected 1)"))); } TEST(AbsTests, exprTest) { diff --git a/tests/src/functions/arithmetic/AddOperTests.cpp b/tests/src/functions/arithmetic/AddOperTests.cpp index da0d2d007..1a5585a88 100644 --- a/tests/src/functions/arithmetic/AddOperTests.cpp +++ b/tests/src/functions/arithmetic/AddOperTests.cpp @@ -4,6 +4,7 @@ #include "fintamath/functions/arithmetic/AddOper.hpp" #include "fintamath/exceptions/InvalidInputException.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Rational.hpp" @@ -48,10 +49,31 @@ TEST(AddOperTests, callTest) { EXPECT_EQ(f(Integer(3), Variable("a"))->toString(), "a + 3"); - EXPECT_THROW(f(Integer(1)), InvalidInputFunctionException); - EXPECT_THROW(f(Rational(2, 3)), InvalidInputFunctionException); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true), Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call AddOper with argument #0 Boolean "True" (expected IArithmetic))"))); + EXPECT_THAT( + [&] { f(Integer(1), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call AddOper with argument #1 Boolean "True" (expected IArithmetic))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call AddOper with 0 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call AddOper with 1 argument (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call AddOper with 3 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call AddOper with 4 arguments (expected 2)"))); } TEST(AddOperTests, getClassTest) { diff --git a/tests/src/functions/arithmetic/AddTests.cpp b/tests/src/functions/arithmetic/AddTests.cpp index 7c7c5816e..1b40b39c9 100644 --- a/tests/src/functions/arithmetic/AddTests.cpp +++ b/tests/src/functions/arithmetic/AddTests.cpp @@ -4,6 +4,7 @@ #include "fintamath/functions/arithmetic/Add.hpp" #include "fintamath/exceptions/InvalidInputException.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -50,7 +51,39 @@ TEST(AddTests, callTest) { EXPECT_EQ(f(Integer(5), Variable("a"))->toString(), "a + 5"); EXPECT_EQ(f(Variable("a"), Variable("a"), Variable("b"))->toString(), "2 a + b"); - EXPECT_THROW(f(), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Add with argument #0 Boolean "True" (expected IArithmetic))"))); + EXPECT_THAT( + [&] { f(Integer(1), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Add with argument #1 Boolean "True" (expected IArithmetic))"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Add with argument #2 Boolean "True" (expected IArithmetic))"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Add with argument #3 Boolean "True" (expected IArithmetic))"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Boolean(true), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Add with argument #2 Boolean "True" (expected IArithmetic))"))); + EXPECT_THAT( + [&] { f(Integer(1), Boolean(true), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Add with argument #1 Boolean "True" (expected IArithmetic))"))); + EXPECT_THAT( + [&] { f(Boolean(true), Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Add with argument #0 Boolean "True" (expected IArithmetic))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Add with 0 arguments (expected > 0)"))); } TEST(AddTests, exprTest) { diff --git a/tests/src/functions/arithmetic/DivTests.cpp b/tests/src/functions/arithmetic/DivTests.cpp index 1785dfac1..0542f15bd 100644 --- a/tests/src/functions/arithmetic/DivTests.cpp +++ b/tests/src/functions/arithmetic/DivTests.cpp @@ -4,6 +4,7 @@ #include "fintamath/functions/arithmetic/Div.hpp" #include "fintamath/exceptions/InvalidInputException.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Rational.hpp" @@ -50,10 +51,31 @@ TEST(DivTests, callTest) { EXPECT_EQ(f(Integer(1), Integer(0))->toString(), "ComplexInf"); EXPECT_EQ(f(Integer(0), Integer(0))->toString(), "Undefined"); - EXPECT_THROW(f(Integer(1)), InvalidInputFunctionException); - EXPECT_THROW(f(Rational(2, 3)), InvalidInputFunctionException); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true), Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Div with argument #0 Boolean "True" (expected IArithmetic))"))); + EXPECT_THAT( + [&] { f(Integer(1), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Div with argument #1 Boolean "True" (expected IArithmetic))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Div with 0 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Div with 1 argument (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Div with 3 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Div with 4 arguments (expected 2)"))); } TEST(DivTests, exprTest) { diff --git a/tests/src/functions/arithmetic/FracMixedTests.cpp b/tests/src/functions/arithmetic/FracMixedTests.cpp index 100a6eadf..627b8ea06 100644 --- a/tests/src/functions/arithmetic/FracMixedTests.cpp +++ b/tests/src/functions/arithmetic/FracMixedTests.cpp @@ -4,6 +4,7 @@ #include "fintamath/functions/arithmetic/FracMixed.hpp" #include "fintamath/exceptions/InvalidInputException.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Rational.hpp" @@ -46,10 +47,35 @@ TEST(FracMixedTests, callTest) { EXPECT_EQ(f(Integer(0), Integer(3), Variable("a"))->toString(), "3/a"); - EXPECT_THROW(f(Integer(1)), InvalidInputFunctionException); - EXPECT_THROW(f(Rational(2, 3)), InvalidInputFunctionException); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call FracMixed with argument #2 Boolean "True" (expected IArithmetic))"))); + EXPECT_THAT( + [&] { f(Integer(1), Boolean(true), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call FracMixed with argument #1 Boolean "True" (expected IArithmetic))"))); + EXPECT_THAT( + [&] { f(Boolean(true), Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call FracMixed with argument #0 Boolean "True" (expected IArithmetic))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call FracMixed with 0 arguments (expected 3)"))); + EXPECT_THAT( + [&] { f(Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call FracMixed with 1 argument (expected 3)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call FracMixed with 2 arguments (expected 3)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call FracMixed with 4 arguments (expected 3)"))); } TEST(FracMixedTests, getClassTest) { diff --git a/tests/src/functions/arithmetic/FracTests.cpp b/tests/src/functions/arithmetic/FracTests.cpp index 1b6e63545..f262d0e4d 100644 --- a/tests/src/functions/arithmetic/FracTests.cpp +++ b/tests/src/functions/arithmetic/FracTests.cpp @@ -4,6 +4,7 @@ #include "fintamath/functions/arithmetic/Frac.hpp" #include "fintamath/exceptions/InvalidInputException.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Rational.hpp" @@ -39,10 +40,31 @@ TEST(FracTests, callTest) { EXPECT_EQ(f(Integer(3), Variable("a"))->toString(), "3/a"); - EXPECT_THROW(f(Integer(1)), InvalidInputFunctionException); - EXPECT_THROW(f(Rational(2, 3)), InvalidInputFunctionException); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true), Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Frac with argument #0 Boolean "True" (expected IArithmetic))"))); + EXPECT_THAT( + [&] { f(Integer(1), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Frac with argument #1 Boolean "True" (expected IArithmetic))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Frac with 0 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Frac with 1 argument (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Frac with 3 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Frac with 4 arguments (expected 2)"))); } TEST(FracTests, getClassTest) { diff --git a/tests/src/functions/arithmetic/MulOperTests.cpp b/tests/src/functions/arithmetic/MulOperTests.cpp index f6bd039fd..3a5b0abe4 100644 --- a/tests/src/functions/arithmetic/MulOperTests.cpp +++ b/tests/src/functions/arithmetic/MulOperTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/arithmetic/MulOper.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Rational.hpp" @@ -46,10 +47,31 @@ TEST(MulOperTests, callTest) { EXPECT_EQ(f(Integer(3), Variable("a"))->toString(), "3 a"); - EXPECT_THROW(f(Integer(1)), InvalidInputFunctionException); - EXPECT_THROW(f(Rational(2, 3)), InvalidInputFunctionException); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true), Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call MulOper with argument #0 Boolean "True" (expected IArithmetic))"))); + EXPECT_THAT( + [&] { f(Integer(1), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call MulOper with argument #1 Boolean "True" (expected IArithmetic))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call MulOper with 0 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call MulOper with 1 argument (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call MulOper with 3 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call MulOper with 4 arguments (expected 2)"))); } TEST(MulOperTests, getClassTest) { diff --git a/tests/src/functions/arithmetic/MulTests.cpp b/tests/src/functions/arithmetic/MulTests.cpp index 976a0f72d..d18d87066 100644 --- a/tests/src/functions/arithmetic/MulTests.cpp +++ b/tests/src/functions/arithmetic/MulTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/arithmetic/Mul.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -50,8 +51,39 @@ TEST(MulTests, callTest) { EXPECT_EQ(f(Integer(5), Variable("a"))->toString(), "5 a"); EXPECT_EQ(f(Variable("a"), Variable("a"), Variable("b"))->toString(), "a^2 b"); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Mul with argument #0 Boolean "True" (expected IArithmetic))"))); + EXPECT_THAT( + [&] { f(Integer(1), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Mul with argument #1 Boolean "True" (expected IArithmetic))"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Mul with argument #2 Boolean "True" (expected IArithmetic))"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Mul with argument #3 Boolean "True" (expected IArithmetic))"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Boolean(true), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Mul with argument #2 Boolean "True" (expected IArithmetic))"))); + EXPECT_THAT( + [&] { f(Integer(1), Boolean(true), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Mul with argument #1 Boolean "True" (expected IArithmetic))"))); + EXPECT_THAT( + [&] { f(Boolean(true), Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Mul with argument #0 Boolean "True" (expected IArithmetic))"))); - EXPECT_THROW(f(), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Mul with 0 arguments (expected > 0)"))); } TEST(MulTests, exprTest) { diff --git a/tests/src/functions/arithmetic/NegTests.cpp b/tests/src/functions/arithmetic/NegTests.cpp index f4f70d82d..b57fcbd85 100644 --- a/tests/src/functions/arithmetic/NegTests.cpp +++ b/tests/src/functions/arithmetic/NegTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/arithmetic/Neg.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Rational.hpp" @@ -45,9 +46,27 @@ TEST(NegTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "-a"); - EXPECT_THROW(f(Integer(1), Rational(2, 3)), InvalidInputFunctionException); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Neg with argument #0 Boolean "True" (expected IArithmetic))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Neg with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Neg with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Neg with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Neg with 4 arguments (expected 1)"))); } TEST(NegTests, exprTest) { diff --git a/tests/src/functions/arithmetic/SignTests.cpp b/tests/src/functions/arithmetic/SignTests.cpp index ab4c5d6d7..19e355a77 100644 --- a/tests/src/functions/arithmetic/SignTests.cpp +++ b/tests/src/functions/arithmetic/SignTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/arithmetic/Sign.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -58,8 +59,27 @@ TEST(SignTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "sign(a)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Sign with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Sign with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Sign with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Sign with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Sign with 4 arguments (expected 1)"))); } TEST(SignTests, exprTest) { diff --git a/tests/src/functions/arithmetic/SubTests.cpp b/tests/src/functions/arithmetic/SubTests.cpp index 600b7a28b..346298a44 100644 --- a/tests/src/functions/arithmetic/SubTests.cpp +++ b/tests/src/functions/arithmetic/SubTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/arithmetic/Sub.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Integer.hpp" #include "fintamath/numbers/Rational.hpp" @@ -48,10 +49,31 @@ TEST(SubTests, callTest) { EXPECT_EQ(f(Integer(3), Variable("a"))->toString(), "-a + 3"); - EXPECT_THROW(f(Integer(1)), InvalidInputFunctionException); - EXPECT_THROW(f(Rational(2, 3)), InvalidInputFunctionException); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true), Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Sub with argument #0 Boolean "True" (expected IArithmetic))"))); + EXPECT_THAT( + [&] { f(Integer(1), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Sub with argument #1 Boolean "True" (expected IArithmetic))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Sub with 0 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Sub with 1 argument (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Sub with 3 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Sub with 4 arguments (expected 2)"))); } TEST(SubTests, exprTest) { diff --git a/tests/src/functions/arithmetic/UnaryPlusTests.cpp b/tests/src/functions/arithmetic/UnaryPlusTests.cpp index 20f38e888..66c44534b 100644 --- a/tests/src/functions/arithmetic/UnaryPlusTests.cpp +++ b/tests/src/functions/arithmetic/UnaryPlusTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/arithmetic/UnaryPlus.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Integer.hpp" #include "fintamath/numbers/Rational.hpp" @@ -46,9 +47,27 @@ TEST(UnaryPlusTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "a"); - EXPECT_THROW(f(Integer(1), Rational(2, 3)), InvalidInputFunctionException); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call UnaryPlus with argument #0 Boolean "True" (expected IArithmetic))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call UnaryPlus with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call UnaryPlus with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call UnaryPlus with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call UnaryPlus with 4 arguments (expected 1)"))); } TEST(UnaryPlusTests, getClassTest) { diff --git a/tests/src/functions/calculus/DerivativeTests.cpp b/tests/src/functions/calculus/DerivativeTests.cpp index 55c78aa93..a10edf891 100644 --- a/tests/src/functions/calculus/DerivativeTests.cpp +++ b/tests/src/functions/calculus/DerivativeTests.cpp @@ -4,6 +4,7 @@ #include "fintamath/functions/calculus/Derivative.hpp" #include "fintamath/expressions/Expression.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Integer.hpp" #include "fintamath/numbers/Rational.hpp" @@ -85,13 +86,31 @@ TEST(DerivativeTests, callTest) { EXPECT_EQ(f(TestComparable(), Variable("a"))->toString(), "derivative(testderivative, a)"); - EXPECT_THROW(f(Integer(5), Integer(1)), InvalidInputException); - EXPECT_THROW(f(Variable("a"), Integer(1)), InvalidInputException); - EXPECT_THROW(f(Variable("a"), Expression("a+a")), InvalidInputException); - - EXPECT_THROW(f(), InvalidInputException); - EXPECT_THROW(f(Integer(1)), InvalidInputException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputException); + EXPECT_THAT( + [&] { f(Boolean(true), Variable("a")); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Derivative with argument #0 Boolean "True" (expected IComparable))"))); + EXPECT_THAT( + [&] { f(Variable("a"), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Derivative with argument #1 Boolean "True" (expected Variable))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Derivative with 0 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Derivative with 1 argument (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Derivative with 3 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Derivative with 4 arguments (expected 2)"))); } TEST(DerivativeTests, exprTest) { diff --git a/tests/src/functions/calculus/IntegralTests.cpp b/tests/src/functions/calculus/IntegralTests.cpp index e34980f3e..e2c26b3aa 100644 --- a/tests/src/functions/calculus/IntegralTests.cpp +++ b/tests/src/functions/calculus/IntegralTests.cpp @@ -4,6 +4,7 @@ #include "fintamath/functions/calculus/Integral.hpp" #include "fintamath/expressions/Expression.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Integer.hpp" #include "fintamath/numbers/Rational.hpp" @@ -39,13 +40,31 @@ TEST(IntegralTests, callTest) { EXPECT_EQ(f(Expression("a+a"), Variable("a"))->toString(), "integral(2 a, a)"); EXPECT_EQ(f(Integer(5), Variable("a"))->toString(), "integral(5, a)"); - EXPECT_THROW(f(Integer(5), Integer(1)), InvalidInputException); - EXPECT_THROW(f(Variable("a"), Integer(1)), InvalidInputException); - EXPECT_THROW(f(Variable("a"), Expression("a+a")), InvalidInputException); + EXPECT_THAT( + [&] { f(Boolean(true), Variable("a")); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Integral with argument #0 Boolean "True" (expected IComparable))"))); + EXPECT_THAT( + [&] { f(Variable("a"), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Integral with argument #1 Boolean "True" (expected Variable))"))); - EXPECT_THROW(f(), InvalidInputException); - EXPECT_THROW(f(Integer(1)), InvalidInputException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputException); + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Integral with 0 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Integral with 1 argument (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Integral with 3 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Integral with 4 arguments (expected 2)"))); } TEST(IntegralTests, exprTest) { diff --git a/tests/src/functions/calculus/MaxTests.cpp b/tests/src/functions/calculus/MaxTests.cpp index 3830c9c75..e1f4ba773 100644 --- a/tests/src/functions/calculus/MaxTests.cpp +++ b/tests/src/functions/calculus/MaxTests.cpp @@ -44,13 +44,39 @@ TEST(MaxTests, callTest) { EXPECT_EQ(f(Rational(-1), Variable("x"), Variable("y"), Integer(1))->toString(), "max(x, y, 1)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Boolean()), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(), Boolean()), InvalidInputFunctionException); - EXPECT_THROW(f(Boolean(), Integer()), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(), Integer(), Boolean()), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(), Boolean(), Integer()), InvalidInputFunctionException); - EXPECT_THROW(f(Boolean(), Integer(), Integer()), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Max with argument #0 Boolean "True" (expected IComparable))"))); + EXPECT_THAT( + [&] { f(Integer(1), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Max with argument #1 Boolean "True" (expected IComparable))"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Max with argument #2 Boolean "True" (expected IComparable))"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Max with argument #3 Boolean "True" (expected IComparable))"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Boolean(true), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Max with argument #2 Boolean "True" (expected IComparable))"))); + EXPECT_THAT( + [&] { f(Integer(1), Boolean(true), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Max with argument #1 Boolean "True" (expected IComparable))"))); + EXPECT_THAT( + [&] { f(Boolean(true), Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Max with argument #0 Boolean "True" (expected IComparable))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Max with 0 arguments (expected > 0)"))); } TEST(MaxTests, exprTest) { diff --git a/tests/src/functions/calculus/MinTests.cpp b/tests/src/functions/calculus/MinTests.cpp index e978e1d2e..13d0f47f4 100644 --- a/tests/src/functions/calculus/MinTests.cpp +++ b/tests/src/functions/calculus/MinTests.cpp @@ -44,13 +44,39 @@ TEST(MinTests, callTest) { EXPECT_EQ(f(Rational(-1), Variable("x"), Variable("y"), Integer(1))->toString(), "min(x, y, -1)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Boolean()), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(), Boolean()), InvalidInputFunctionException); - EXPECT_THROW(f(Boolean(), Integer()), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(), Integer(), Boolean()), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(), Boolean(), Integer()), InvalidInputFunctionException); - EXPECT_THROW(f(Boolean(), Integer(), Integer()), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Min with argument #0 Boolean "True" (expected IComparable))"))); + EXPECT_THAT( + [&] { f(Integer(1), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Min with argument #1 Boolean "True" (expected IComparable))"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Min with argument #2 Boolean "True" (expected IComparable))"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Min with argument #3 Boolean "True" (expected IComparable))"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Boolean(true), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Min with argument #2 Boolean "True" (expected IComparable))"))); + EXPECT_THAT( + [&] { f(Integer(1), Boolean(true), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Min with argument #1 Boolean "True" (expected IComparable))"))); + EXPECT_THAT( + [&] { f(Boolean(true), Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Min with argument #0 Boolean "True" (expected IComparable))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Min with 0 arguments (expected > 0)"))); } TEST(MinTests, exprTest) { diff --git a/tests/src/functions/comparison/EqvTests.cpp b/tests/src/functions/comparison/EqvTests.cpp index 1fa170f84..92f5aa7d2 100644 --- a/tests/src/functions/comparison/EqvTests.cpp +++ b/tests/src/functions/comparison/EqvTests.cpp @@ -54,10 +54,31 @@ TEST(EqvTests, callTest) { EXPECT_EQ(f(Integer(3), Variable("a"))->toString(), "a - 3 = 0"); EXPECT_EQ(f(Variable("a"), Variable("a"))->toString(), "True"); - EXPECT_THROW(f(Integer(1)), InvalidInputFunctionException); - EXPECT_THROW(f(Rational(2, 3)), InvalidInputFunctionException); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true), Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Eqv with argument #0 Boolean "True" (expected IComparable))"))); + EXPECT_THAT( + [&] { f(Integer(1), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Eqv with argument #1 Boolean "True" (expected IComparable))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Eqv with 0 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Eqv with 1 argument (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Eqv with 3 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Eqv with 4 arguments (expected 2)"))); } TEST(EqvTests, exprTest) { diff --git a/tests/src/functions/comparison/LessEqvTests.cpp b/tests/src/functions/comparison/LessEqvTests.cpp index b4b4e1612..1cd3fb4b2 100644 --- a/tests/src/functions/comparison/LessEqvTests.cpp +++ b/tests/src/functions/comparison/LessEqvTests.cpp @@ -54,10 +54,31 @@ TEST(LessEqvTests, callTest) { EXPECT_EQ(f(Integer(3), Variable("a"))->toString(), "a - 3 >= 0"); EXPECT_EQ(f(Variable("a"), Variable("a"))->toString(), "True"); - EXPECT_THROW(f(Integer(1)), InvalidInputFunctionException); - EXPECT_THROW(f(Rational(2, 3)), InvalidInputFunctionException); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true), Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call LessEqv with argument #0 Boolean "True" (expected IComparable))"))); + EXPECT_THAT( + [&] { f(Integer(1), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call LessEqv with argument #1 Boolean "True" (expected IComparable))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call LessEqv with 0 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call LessEqv with 1 argument (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call LessEqv with 3 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call LessEqv with 4 arguments (expected 2)"))); } TEST(LessEqvTests, exprTest) { diff --git a/tests/src/functions/comparison/LessTests.cpp b/tests/src/functions/comparison/LessTests.cpp index 4d36a2068..0fb6bebc9 100644 --- a/tests/src/functions/comparison/LessTests.cpp +++ b/tests/src/functions/comparison/LessTests.cpp @@ -54,10 +54,31 @@ TEST(LessTests, callTest) { EXPECT_EQ(f(Integer(3), Variable("a"))->toString(), "a - 3 > 0"); EXPECT_EQ(f(Variable("a"), Variable("a"))->toString(), "False"); - EXPECT_THROW(f(Integer(1)), InvalidInputFunctionException); - EXPECT_THROW(f(Rational(2, 3)), InvalidInputFunctionException); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true), Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Less with argument #0 Boolean "True" (expected IComparable))"))); + EXPECT_THAT( + [&] { f(Integer(1), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Less with argument #1 Boolean "True" (expected IComparable))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Less with 0 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Less with 1 argument (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Less with 3 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Less with 4 arguments (expected 2)"))); } TEST(LessTests, exprTest) { diff --git a/tests/src/functions/comparison/MoreEqvTests.cpp b/tests/src/functions/comparison/MoreEqvTests.cpp index b8ea36c27..00061d660 100644 --- a/tests/src/functions/comparison/MoreEqvTests.cpp +++ b/tests/src/functions/comparison/MoreEqvTests.cpp @@ -54,10 +54,31 @@ TEST(MoreEqvTests, callTest) { EXPECT_EQ(f(Integer(3), Variable("a"))->toString(), "a - 3 <= 0"); EXPECT_EQ(f(Variable("a"), Variable("a"))->toString(), "True"); - EXPECT_THROW(f(Integer(1)), InvalidInputFunctionException); - EXPECT_THROW(f(Rational(2, 3)), InvalidInputFunctionException); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true), Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call MoreEqv with argument #0 Boolean "True" (expected IComparable))"))); + EXPECT_THAT( + [&] { f(Integer(1), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call MoreEqv with argument #1 Boolean "True" (expected IComparable))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call MoreEqv with 0 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call MoreEqv with 1 argument (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call MoreEqv with 3 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call MoreEqv with 4 arguments (expected 2)"))); } TEST(MoreEqvTests, exprTest) { diff --git a/tests/src/functions/comparison/MoreTests.cpp b/tests/src/functions/comparison/MoreTests.cpp index 25a64b474..e187b34df 100644 --- a/tests/src/functions/comparison/MoreTests.cpp +++ b/tests/src/functions/comparison/MoreTests.cpp @@ -54,10 +54,31 @@ TEST(MoreTests, callTest) { EXPECT_EQ(f(Integer(3), Variable("a"))->toString(), "a - 3 < 0"); EXPECT_EQ(f(Variable("a"), Variable("a"))->toString(), "False"); - EXPECT_THROW(f(Integer(1)), InvalidInputFunctionException); - EXPECT_THROW(f(Rational(2, 3)), InvalidInputFunctionException); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true), Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call More with argument #0 Boolean "True" (expected IComparable))"))); + EXPECT_THAT( + [&] { f(Integer(1), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call More with argument #1 Boolean "True" (expected IComparable))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call More with 0 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call More with 1 argument (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call More with 3 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call More with 4 arguments (expected 2)"))); } TEST(MoreTests, exprTest) { diff --git a/tests/src/functions/comparison/NeqvTests.cpp b/tests/src/functions/comparison/NeqvTests.cpp index cb9fac49a..1638dbb4c 100644 --- a/tests/src/functions/comparison/NeqvTests.cpp +++ b/tests/src/functions/comparison/NeqvTests.cpp @@ -54,10 +54,31 @@ TEST(NeqvTests, callTest) { EXPECT_EQ(f(Integer(3), Variable("a"))->toString(), "a - 3 != 0"); EXPECT_EQ(f(Variable("a"), Variable("a"))->toString(), "False"); - EXPECT_THROW(f(Integer(1)), InvalidInputFunctionException); - EXPECT_THROW(f(Rational(2, 3)), InvalidInputFunctionException); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true), Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Neqv with argument #0 Boolean "True" (expected IComparable))"))); + EXPECT_THAT( + [&] { f(Integer(1), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Neqv with argument #1 Boolean "True" (expected IComparable))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Neqv with 0 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Neqv with 1 argument (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Neqv with 3 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Neqv with 4 arguments (expected 2)"))); } TEST(NeqvTests, exprTest) { diff --git a/tests/src/functions/hyperbolic/AcoshTests.cpp b/tests/src/functions/hyperbolic/AcoshTests.cpp index f1756259d..bab244ceb 100644 --- a/tests/src/functions/hyperbolic/AcoshTests.cpp +++ b/tests/src/functions/hyperbolic/AcoshTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/hyperbolic/Acosh.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -48,8 +49,27 @@ TEST(AcoshTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "acosh(a)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Acosh with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Acosh with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Acosh with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Acosh with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Acosh with 4 arguments (expected 1)"))); } TEST(AcoshTests, exprTest) { diff --git a/tests/src/functions/hyperbolic/AcothTests.cpp b/tests/src/functions/hyperbolic/AcothTests.cpp index 6e0632490..7ced90f76 100644 --- a/tests/src/functions/hyperbolic/AcothTests.cpp +++ b/tests/src/functions/hyperbolic/AcothTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/hyperbolic/Acoth.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -48,8 +49,27 @@ TEST(AcothTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "acoth(a)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Acoth with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Acoth with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Acoth with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Acoth with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Acoth with 4 arguments (expected 1)"))); } TEST(AcothTests, exprTest) { diff --git a/tests/src/functions/hyperbolic/AcschTests.cpp b/tests/src/functions/hyperbolic/AcschTests.cpp index a770081ee..52a20227a 100644 --- a/tests/src/functions/hyperbolic/AcschTests.cpp +++ b/tests/src/functions/hyperbolic/AcschTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/hyperbolic/Acsch.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -47,8 +48,27 @@ TEST(AcschTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "acsch(a)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Acsch with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Acsch with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Acsch with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Acsch with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Acsch with 4 arguments (expected 1)"))); } TEST(AcschTests, exprTest) { diff --git a/tests/src/functions/hyperbolic/AsechTests.cpp b/tests/src/functions/hyperbolic/AsechTests.cpp index d74dfa16e..a83fde033 100644 --- a/tests/src/functions/hyperbolic/AsechTests.cpp +++ b/tests/src/functions/hyperbolic/AsechTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/hyperbolic/Asech.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -48,8 +49,27 @@ TEST(AsechTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "asech(a)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Asech with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Asech with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Asech with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Asech with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Asech with 4 arguments (expected 1)"))); } TEST(AsechTests, exprTest) { diff --git a/tests/src/functions/hyperbolic/AsinhTests.cpp b/tests/src/functions/hyperbolic/AsinhTests.cpp index 0eccdfbd8..d1c43cad0 100644 --- a/tests/src/functions/hyperbolic/AsinhTests.cpp +++ b/tests/src/functions/hyperbolic/AsinhTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/hyperbolic/Asinh.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -45,8 +46,27 @@ TEST(AsinhTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "asinh(a)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Asinh with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Asinh with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Asinh with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Asinh with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Asinh with 4 arguments (expected 1)"))); } TEST(AsinhTests, exprTest) { diff --git a/tests/src/functions/hyperbolic/AtanhTests.cpp b/tests/src/functions/hyperbolic/AtanhTests.cpp index 77f264830..81552ffbe 100644 --- a/tests/src/functions/hyperbolic/AtanhTests.cpp +++ b/tests/src/functions/hyperbolic/AtanhTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/hyperbolic/Atanh.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -48,8 +49,27 @@ TEST(AtanhTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "atanh(a)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Atanh with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Atanh with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Atanh with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Atanh with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Atanh with 4 arguments (expected 1)"))); } TEST(AtanhTests, exprTest) { diff --git a/tests/src/functions/hyperbolic/CoshTests.cpp b/tests/src/functions/hyperbolic/CoshTests.cpp index 4df0ffc25..ba83e28f5 100644 --- a/tests/src/functions/hyperbolic/CoshTests.cpp +++ b/tests/src/functions/hyperbolic/CoshTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/hyperbolic/Cosh.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -45,8 +46,27 @@ TEST(CoshTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "cosh(a)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Cosh with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Cosh with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Cosh with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Cosh with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Cosh with 4 arguments (expected 1)"))); } TEST(CoshTests, exprTest) { diff --git a/tests/src/functions/hyperbolic/CothTests.cpp b/tests/src/functions/hyperbolic/CothTests.cpp index ea2feca67..094fe733a 100644 --- a/tests/src/functions/hyperbolic/CothTests.cpp +++ b/tests/src/functions/hyperbolic/CothTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/hyperbolic/Coth.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -46,8 +47,27 @@ TEST(CothTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "coth(a)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Coth with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Coth with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Coth with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Coth with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Coth with 4 arguments (expected 1)"))); } TEST(CothTests, exprTest) { diff --git a/tests/src/functions/hyperbolic/CschTests.cpp b/tests/src/functions/hyperbolic/CschTests.cpp index 3ec09c1dc..bd6e8ab9d 100644 --- a/tests/src/functions/hyperbolic/CschTests.cpp +++ b/tests/src/functions/hyperbolic/CschTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/hyperbolic/Csch.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -45,8 +46,27 @@ TEST(CschTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "csch(a)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Csch with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Csch with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Csch with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Csch with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Csch with 4 arguments (expected 1)"))); } TEST(CschTests, exprTest) { diff --git a/tests/src/functions/hyperbolic/SechTests.cpp b/tests/src/functions/hyperbolic/SechTests.cpp index 675400b6f..346a7fef7 100644 --- a/tests/src/functions/hyperbolic/SechTests.cpp +++ b/tests/src/functions/hyperbolic/SechTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/hyperbolic/Sech.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -46,8 +47,27 @@ TEST(SechTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "sech(a)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Sech with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Sech with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Sech with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Sech with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Sech with 4 arguments (expected 1)"))); } TEST(SechTests, exprTest) { diff --git a/tests/src/functions/hyperbolic/SinhTests.cpp b/tests/src/functions/hyperbolic/SinhTests.cpp index 1928fd5dd..bb8ac9548 100644 --- a/tests/src/functions/hyperbolic/SinhTests.cpp +++ b/tests/src/functions/hyperbolic/SinhTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/hyperbolic/Sinh.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -45,8 +46,27 @@ TEST(SinhTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "sinh(a)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Sinh with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Sinh with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Sinh with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Sinh with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Sinh with 4 arguments (expected 1)"))); } TEST(SinhTests, exprTest) { diff --git a/tests/src/functions/hyperbolic/TanhTests.cpp b/tests/src/functions/hyperbolic/TanhTests.cpp index 54a0a3ca6..46a565475 100644 --- a/tests/src/functions/hyperbolic/TanhTests.cpp +++ b/tests/src/functions/hyperbolic/TanhTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/hyperbolic/Tanh.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -45,8 +46,27 @@ TEST(TanhTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "tanh(a)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Tanh with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Tanh with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Tanh with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Tanh with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Tanh with 4 arguments (expected 1)"))); } TEST(TanhTests, exprTest) { diff --git a/tests/src/functions/logarithms/LbTests.cpp b/tests/src/functions/logarithms/LbTests.cpp index 2168123cc..d8096cfee 100644 --- a/tests/src/functions/logarithms/LbTests.cpp +++ b/tests/src/functions/logarithms/LbTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/logarithms/Lb.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Rational.hpp" @@ -41,8 +42,27 @@ TEST(LbTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "log(2, a)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(10), Integer(10), Integer(10)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Lb with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Lb with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Lb with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Lb with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Lb with 4 arguments (expected 1)"))); } TEST(LbTests, exprTest) { diff --git a/tests/src/functions/logarithms/LgTests.cpp b/tests/src/functions/logarithms/LgTests.cpp index 19010d9fa..dba3bd982 100644 --- a/tests/src/functions/logarithms/LgTests.cpp +++ b/tests/src/functions/logarithms/LgTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/logarithms/Lg.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Rational.hpp" @@ -41,8 +42,27 @@ TEST(LgTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "log(10, a)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(10), Integer(10), Integer(10)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Lg with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Lg with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Lg with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Lg with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Lg with 4 arguments (expected 1)"))); } TEST(LgTests, exprTest) { diff --git a/tests/src/functions/logarithms/LnTests.cpp b/tests/src/functions/logarithms/LnTests.cpp index 4666aa6d5..1d61d3f0d 100644 --- a/tests/src/functions/logarithms/LnTests.cpp +++ b/tests/src/functions/logarithms/LnTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/logarithms/Ln.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Integer.hpp" #include "fintamath/numbers/Rational.hpp" @@ -43,8 +44,27 @@ TEST(LnTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "ln(a)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Ln with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Ln with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Ln with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Ln with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Ln with 4 arguments (expected 1)"))); } TEST(LnTests, exprTest) { diff --git a/tests/src/functions/logarithms/LogTests.cpp b/tests/src/functions/logarithms/LogTests.cpp index 3480d6252..e7062ba7a 100644 --- a/tests/src/functions/logarithms/LogTests.cpp +++ b/tests/src/functions/logarithms/LogTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/logarithms/Log.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -121,9 +122,31 @@ TEST(LogTests, callTest) { EXPECT_EQ(f(Variable("a"), Variable("b"))->toString(), "log(a, b)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(10)), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(10), Integer(10), Integer(10)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true), Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Log with argument #0 Boolean "True" (expected INumber))"))); + EXPECT_THAT( + [&] { f(Integer(1), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Log with argument #1 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Log with 0 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Log with 1 argument (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Log with 3 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Log with 4 arguments (expected 2)"))); } TEST(LogTests, exprTest) { diff --git a/tests/src/functions/logic/AndOperTests.cpp b/tests/src/functions/logic/AndOperTests.cpp index f3cc302fb..ec82ede66 100644 --- a/tests/src/functions/logic/AndOperTests.cpp +++ b/tests/src/functions/logic/AndOperTests.cpp @@ -46,9 +46,31 @@ TEST(AndOperTests, callTest) { EXPECT_EQ(f(Variable("a"), Variable("b"))->toString(), "a & b"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Boolean(true)), InvalidInputFunctionException); - EXPECT_THROW(f(Boolean(true), Boolean(true), Boolean(true)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Integer(1), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call AndOper with argument #0 Integer "1" (expected Boolean))"))); + EXPECT_THAT( + [&] { f(Boolean(true), Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call AndOper with argument #1 Integer "1" (expected Boolean))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call AndOper with 0 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call AndOper with 1 argument (expected 2)"))); + EXPECT_THAT( + [&] { f(Boolean(true), Boolean(false), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call AndOper with 3 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Boolean(true), Boolean(false), Boolean(true), Boolean(false)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call AndOper with 4 arguments (expected 2)"))); } TEST(AndOperTests, getClassTest) { diff --git a/tests/src/functions/logic/AndTests.cpp b/tests/src/functions/logic/AndTests.cpp index a3abd7768..80740189b 100644 --- a/tests/src/functions/logic/AndTests.cpp +++ b/tests/src/functions/logic/AndTests.cpp @@ -55,7 +55,39 @@ TEST(AndTests, callTest) { EXPECT_EQ(f(Variable("a"), Variable("b"), Boolean("True"), Variable("c"))->toString(), "a & b & c"); EXPECT_EQ(f(Boolean("False"), Variable("a"), Variable("b"), Variable("c"))->toString(), "False"); - EXPECT_THROW(f(), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call And with argument #0 Integer "1" (expected Boolean))"))); + EXPECT_THAT( + [&] { f(Boolean(true), Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call And with argument #1 Integer "1" (expected Boolean))"))); + EXPECT_THAT( + [&] { f(Boolean(true), Boolean(false), Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call And with argument #2 Integer "1" (expected Boolean))"))); + EXPECT_THAT( + [&] { f(Boolean(true), Boolean(false), Boolean(true), Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call And with argument #3 Integer "1" (expected Boolean))"))); + EXPECT_THAT( + [&] { f(Boolean(true), Boolean(false), Integer(1), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call And with argument #2 Integer "1" (expected Boolean))"))); + EXPECT_THAT( + [&] { f(Boolean(true), Integer(1), Boolean(false), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call And with argument #1 Integer "1" (expected Boolean))"))); + EXPECT_THAT( + [&] { f(Integer(1), Boolean(true), Boolean(false), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call And with argument #0 Integer "1" (expected Boolean))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call And with 0 arguments (expected > 0)"))); } TEST(AndTests, exprTest) { diff --git a/tests/src/functions/logic/EquivTests.cpp b/tests/src/functions/logic/EquivTests.cpp index 6e190f64c..affdae599 100644 --- a/tests/src/functions/logic/EquivTests.cpp +++ b/tests/src/functions/logic/EquivTests.cpp @@ -46,9 +46,31 @@ TEST(EquivTests, callTest) { EXPECT_EQ(f(Variable("a"), Variable("b"))->toString(), "(~a & ~b) | (a & b)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Boolean(true)), InvalidInputFunctionException); - EXPECT_THROW(f(Boolean(true), Boolean(true), Boolean(true)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Integer(1), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Equiv with argument #0 Integer "1" (expected Boolean))"))); + EXPECT_THAT( + [&] { f(Boolean(true), Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Equiv with argument #1 Integer "1" (expected Boolean))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Equiv with 0 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Equiv with 1 argument (expected 2)"))); + EXPECT_THAT( + [&] { f(Boolean(true), Boolean(false), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Equiv with 3 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Boolean(true), Boolean(false), Boolean(true), Boolean(false)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Equiv with 4 arguments (expected 2)"))); } TEST(EquivTests, exprTest) { diff --git a/tests/src/functions/logic/ImplTests.cpp b/tests/src/functions/logic/ImplTests.cpp index 9f4c5a70d..594c9cee4 100644 --- a/tests/src/functions/logic/ImplTests.cpp +++ b/tests/src/functions/logic/ImplTests.cpp @@ -46,9 +46,31 @@ TEST(ImplTests, callTest) { EXPECT_EQ(f(Variable("a"), Variable("b"))->toString(), "~a | b"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Boolean(true)), InvalidInputFunctionException); - EXPECT_THROW(f(Boolean(true), Boolean(true), Boolean(true)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Integer(1), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Impl with argument #0 Integer "1" (expected Boolean))"))); + EXPECT_THAT( + [&] { f(Boolean(true), Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Impl with argument #1 Integer "1" (expected Boolean))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Impl with 0 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Impl with 1 argument (expected 2)"))); + EXPECT_THAT( + [&] { f(Boolean(true), Boolean(false), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Impl with 3 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Boolean(true), Boolean(false), Boolean(true), Boolean(false)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Impl with 4 arguments (expected 2)"))); } TEST(ImplTests, exprTest) { diff --git a/tests/src/functions/logic/NequivTests.cpp b/tests/src/functions/logic/NequivTests.cpp index 400156eb8..5c6b48b01 100644 --- a/tests/src/functions/logic/NequivTests.cpp +++ b/tests/src/functions/logic/NequivTests.cpp @@ -46,9 +46,31 @@ TEST(NequivTests, callTest) { EXPECT_EQ(f(Variable("a"), Variable("b"))->toString(), "(~a & b) | (a & ~b)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Boolean(true)), InvalidInputFunctionException); - EXPECT_THROW(f(Boolean(true), Boolean(true), Boolean(true)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Integer(1), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Nequiv with argument #0 Integer "1" (expected Boolean))"))); + EXPECT_THAT( + [&] { f(Boolean(true), Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Nequiv with argument #1 Integer "1" (expected Boolean))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Nequiv with 0 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Nequiv with 1 argument (expected 2)"))); + EXPECT_THAT( + [&] { f(Boolean(true), Boolean(false), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Nequiv with 3 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Boolean(true), Boolean(false), Boolean(true), Boolean(false)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Nequiv with 4 arguments (expected 2)"))); } TEST(NequivTests, exprTest) { diff --git a/tests/src/functions/logic/NotTests.cpp b/tests/src/functions/logic/NotTests.cpp index 2ab7adddb..3fc027d06 100644 --- a/tests/src/functions/logic/NotTests.cpp +++ b/tests/src/functions/logic/NotTests.cpp @@ -44,9 +44,27 @@ TEST(NotTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "~a"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Boolean(true), Boolean(true)), InvalidInputFunctionException); - EXPECT_THROW(f(Boolean(true), Boolean(true), Boolean(true)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Not with argument #0 Integer "1" (expected Boolean))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Not with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Boolean(true), Boolean(false)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Not with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Boolean(true), Boolean(false), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Not with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Boolean(true), Boolean(false), Boolean(true), Boolean(false)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Not with 4 arguments (expected 1)"))); } TEST(NotTests, exprTest) { diff --git a/tests/src/functions/logic/OrOperTests.cpp b/tests/src/functions/logic/OrOperTests.cpp index affe97223..9006776d5 100644 --- a/tests/src/functions/logic/OrOperTests.cpp +++ b/tests/src/functions/logic/OrOperTests.cpp @@ -46,9 +46,31 @@ TEST(OrOperTests, callTest) { EXPECT_EQ(f(Variable("a"), Variable("b"))->toString(), "a | b"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Boolean(true)), InvalidInputFunctionException); - EXPECT_THROW(f(Boolean(true), Boolean(true), Boolean(true)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Integer(1), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call OrOper with argument #0 Integer "1" (expected Boolean))"))); + EXPECT_THAT( + [&] { f(Boolean(true), Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call OrOper with argument #1 Integer "1" (expected Boolean))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call OrOper with 0 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call OrOper with 1 argument (expected 2)"))); + EXPECT_THAT( + [&] { f(Boolean(true), Boolean(false), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call OrOper with 3 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Boolean(true), Boolean(false), Boolean(true), Boolean(false)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call OrOper with 4 arguments (expected 2)"))); } TEST(OrOperTests, getClassTest) { diff --git a/tests/src/functions/logic/OrTests.cpp b/tests/src/functions/logic/OrTests.cpp index efc8089b6..162955a8e 100644 --- a/tests/src/functions/logic/OrTests.cpp +++ b/tests/src/functions/logic/OrTests.cpp @@ -55,7 +55,39 @@ TEST(OrTests, callTest) { EXPECT_EQ(f(Variable("a"), Variable("b"), Boolean("True"), Variable("c"))->toString(), "True"); EXPECT_EQ(f(Boolean("False"), Variable("a"), Variable("b"), Variable("c"))->toString(), "a | b | c"); - EXPECT_THROW(f(), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Or with argument #0 Integer "1" (expected Boolean))"))); + EXPECT_THAT( + [&] { f(Boolean(true), Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Or with argument #1 Integer "1" (expected Boolean))"))); + EXPECT_THAT( + [&] { f(Boolean(true), Boolean(false), Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Or with argument #2 Integer "1" (expected Boolean))"))); + EXPECT_THAT( + [&] { f(Boolean(true), Boolean(false), Boolean(true), Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Or with argument #3 Integer "1" (expected Boolean))"))); + EXPECT_THAT( + [&] { f(Boolean(true), Boolean(false), Integer(1), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Or with argument #2 Integer "1" (expected Boolean))"))); + EXPECT_THAT( + [&] { f(Boolean(true), Integer(1), Boolean(false), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Or with argument #1 Integer "1" (expected Boolean))"))); + EXPECT_THAT( + [&] { f(Integer(1), Boolean(true), Boolean(false), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Or with argument #0 Integer "1" (expected Boolean))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Or with 0 arguments (expected > 0)"))); } TEST(OrTests, exprTest) { diff --git a/tests/src/functions/ntheory/CeilTests.cpp b/tests/src/functions/ntheory/CeilTests.cpp index 76ad3c129..d3683892d 100644 --- a/tests/src/functions/ntheory/CeilTests.cpp +++ b/tests/src/functions/ntheory/CeilTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/ntheory/Ceil.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -71,8 +72,27 @@ TEST(CeilTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "ceil(a)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Ceil with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Ceil with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Ceil with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Ceil with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Ceil with 4 arguments (expected 1)"))); } TEST(CeilTests, exprTest) { diff --git a/tests/src/functions/ntheory/FloorTests.cpp b/tests/src/functions/ntheory/FloorTests.cpp index 2c5e0120c..46431d373 100644 --- a/tests/src/functions/ntheory/FloorTests.cpp +++ b/tests/src/functions/ntheory/FloorTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/ntheory/Floor.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -71,8 +72,27 @@ TEST(FloorTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "floor(a)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Floor with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Floor with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Floor with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Floor with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Floor with 4 arguments (expected 1)"))); } TEST(FloorTests, exprTest) { diff --git a/tests/src/functions/ntheory/ModTests.cpp b/tests/src/functions/ntheory/ModTests.cpp index 2de2d5f8c..b91ee0a0a 100644 --- a/tests/src/functions/ntheory/ModTests.cpp +++ b/tests/src/functions/ntheory/ModTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/ntheory/Mod.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -88,10 +89,31 @@ TEST(ModTests, callTest) { EXPECT_EQ(f(Integer(3), Variable("a"))->toString(), "3 mod a"); - EXPECT_THROW(f(Integer(1)), InvalidInputFunctionException); - EXPECT_THROW(f(Rational(2, 3)), InvalidInputFunctionException); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true), Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Mod with argument #0 Boolean "True" (expected INumber))"))); + EXPECT_THAT( + [&] { f(Integer(1), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Mod with argument #1 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Mod with 0 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Mod with 1 argument (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Mod with 3 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Mod with 4 arguments (expected 2)"))); } TEST(ModTests, exprTest) { diff --git a/tests/src/functions/other/CommaTests.cpp b/tests/src/functions/other/CommaTests.cpp index d769dc380..5ae9a194e 100644 --- a/tests/src/functions/other/CommaTests.cpp +++ b/tests/src/functions/other/CommaTests.cpp @@ -4,6 +4,7 @@ #include "fintamath/functions/other/Comma.hpp" #include "fintamath/expressions/Expression.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Integer.hpp" @@ -40,10 +41,27 @@ TEST(CommaTests, isAssociativeTest) { } TEST(CommaTests, callTest) { - EXPECT_THROW(f(Variable("a"), Variable("a"))->toString(), InvalidInputException); + EXPECT_THAT( + [&] { f(Variable("a"), Variable("a")); }, + testing::ThrowsMessage( + testing::StrEq("Calling Comma directly is not allowed"))); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Comma with 0 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Comma with 1 argument (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Comma with 3 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Comma with 4 arguments (expected 2)"))); } TEST(CommaTests, exprTest) { diff --git a/tests/src/functions/other/DegTests.cpp b/tests/src/functions/other/DegTests.cpp index b01a7171e..33b8cfb80 100644 --- a/tests/src/functions/other/DegTests.cpp +++ b/tests/src/functions/other/DegTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/other/Deg.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Rational.hpp" @@ -47,8 +48,27 @@ TEST(DegTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "(Pi a)/180"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Deg with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Deg with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Deg with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Deg with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Deg with 4 arguments (expected 1)"))); } TEST(DegTests, degTest) { diff --git a/tests/src/functions/other/FactorialTests.cpp b/tests/src/functions/other/FactorialTests.cpp index 92c0f0ad2..2d49994fe 100644 --- a/tests/src/functions/other/FactorialTests.cpp +++ b/tests/src/functions/other/FactorialTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/other/Factorial.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -67,8 +68,27 @@ TEST(FactorialTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "a!"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Factorial with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Factorial with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Factorial with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Factorial with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Factorial with 4 arguments (expected 1)"))); } TEST(FactorialTests, callDoubleFactorialTest) { @@ -93,9 +113,6 @@ TEST(FactorialTests, callDoubleFactorialTest) { EXPECT_EQ(f2(Real(-10))->toString(), "(-10.0)!!"); EXPECT_EQ(f2(Variable("a"))->toString(), "a!!"); - - EXPECT_THROW(f2(), InvalidInputFunctionException); - EXPECT_THROW(f2(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); } TEST(FactorialTests, callTripleFactorialTest) { @@ -120,9 +137,6 @@ TEST(FactorialTests, callTripleFactorialTest) { EXPECT_EQ(f3(Real(-10))->toString(), "(-10.0)!!!"); EXPECT_EQ(f3(Variable("a"))->toString(), "a!!!"); - - EXPECT_THROW(f3(), InvalidInputFunctionException); - EXPECT_THROW(f3(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); } TEST(FactorialTests, getSetOrderTest) { diff --git a/tests/src/functions/other/IndexTests.cpp b/tests/src/functions/other/IndexTests.cpp index b15baf11a..47151227a 100644 --- a/tests/src/functions/other/IndexTests.cpp +++ b/tests/src/functions/other/IndexTests.cpp @@ -4,6 +4,7 @@ #include "fintamath/functions/other/Index.hpp" #include "fintamath/expressions/Expression.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Integer.hpp" @@ -46,16 +47,31 @@ TEST(IndexTests, callTest) { EXPECT_EQ(f(Variable("a"), Integer("100000000000000000000000000000000"))->toString(), "a_100000000000000000000000000000000"); - EXPECT_THROW(f(Variable("a"), Variable("a"))->toString(), InvalidInputException); - EXPECT_THROW(f(Variable("a"), Expression("a+1"))->toString(), InvalidInputException); - EXPECT_THROW(f(Expression("a"), Integer(-1))->toString(), InvalidInputException); - EXPECT_THROW(f(Expression("1"), Integer(2))->toString(), InvalidInputException); - EXPECT_THROW(f(Expression("a+1"), Integer(2))->toString(), InvalidInputException); - EXPECT_THROW(f(Expression("a+1"), Expression("a+1"))->toString(), InvalidInputException); - EXPECT_THROW(f(Expression("a"), Expression("a>1"))->toString(), InvalidInputException); - - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true), Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Index with argument #0 Boolean "True" (expected Variable))"))); + EXPECT_THAT( + [&] { f(Variable("a"), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Index with argument #1 Boolean "True" (expected Integer))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Index with 0 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Index with 1 argument (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Index with 3 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Index with 4 arguments (expected 2)"))); } TEST(IndexTests, exprTest) { diff --git a/tests/src/functions/other/PercentTests.cpp b/tests/src/functions/other/PercentTests.cpp index e1812b26f..ac02f6abf 100644 --- a/tests/src/functions/other/PercentTests.cpp +++ b/tests/src/functions/other/PercentTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/other/Percent.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Rational.hpp" @@ -46,8 +47,27 @@ TEST(PercentTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "a/100"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Percent with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Percent with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Percent with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Percent with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Percent with 4 arguments (expected 1)"))); } TEST(PercentTests, degTest) { diff --git a/tests/src/functions/powers/ExpTests.cpp b/tests/src/functions/powers/ExpTests.cpp index c00995609..413100d1c 100644 --- a/tests/src/functions/powers/ExpTests.cpp +++ b/tests/src/functions/powers/ExpTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/powers/Exp.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Rational.hpp" @@ -37,8 +38,27 @@ TEST(ExpTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "E^a"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Exp with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Exp with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Exp with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Exp with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Exp with 4 arguments (expected 1)"))); } TEST(ExpTests, exprTest) { diff --git a/tests/src/functions/powers/PowOperTests.cpp b/tests/src/functions/powers/PowOperTests.cpp index 86579ba42..4fccb3bbc 100644 --- a/tests/src/functions/powers/PowOperTests.cpp +++ b/tests/src/functions/powers/PowOperTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/powers/PowOper.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -48,10 +49,31 @@ TEST(PowOperTests, callTest) { EXPECT_EQ(f(Variable("a"), Rational(1, 2))->toString(), "sqrt(a)"); EXPECT_EQ(f(Variable("a"), Rational(3, 2))->toString(), "a^(3/2)"); - EXPECT_THROW(f(), InvalidInputException); - EXPECT_THROW(f(Integer(1)), InvalidInputException); - EXPECT_THROW(f(Rational(2, 3)), InvalidInputException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputException); + EXPECT_THAT( + [&] { f(Boolean(true), Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call PowOper with argument #0 Boolean "True" (expected INumber))"))); + EXPECT_THAT( + [&] { f(Integer(1), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call PowOper with argument #1 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call PowOper with 0 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call PowOper with 1 argument (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call PowOper with 3 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call PowOper with 4 arguments (expected 2)"))); } TEST(PowOperTests, getClassTest) { diff --git a/tests/src/functions/powers/PowTests.cpp b/tests/src/functions/powers/PowTests.cpp index 383723c0a..aaf6fd117 100644 --- a/tests/src/functions/powers/PowTests.cpp +++ b/tests/src/functions/powers/PowTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/powers/Pow.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -149,10 +150,31 @@ TEST(PowTests, callTest) { EXPECT_EQ(f(Variable("a"), Rational(3, 2))->toString(), "a^(3/2)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1)), InvalidInputFunctionException); - EXPECT_THROW(f(Rational(2, 3)), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true), Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Pow with argument #0 Boolean "True" (expected INumber))"))); + EXPECT_THAT( + [&] { f(Integer(1), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Pow with argument #1 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Pow with 0 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Pow with 1 argument (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Pow with 3 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Pow with 4 arguments (expected 2)"))); } TEST(PowTests, exprTest) { diff --git a/tests/src/functions/powers/RootTests.cpp b/tests/src/functions/powers/RootTests.cpp index 1fc401358..00c282d74 100644 --- a/tests/src/functions/powers/RootTests.cpp +++ b/tests/src/functions/powers/RootTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/powers/Root.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Rational.hpp" #include "fintamath/numbers/Real.hpp" @@ -173,8 +174,31 @@ TEST(RootTests, callTest) { EXPECT_EQ(f(Integer(2), Variable("a"))->toString(), "root(2, a)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true), Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Root with argument #0 Boolean "True" (expected INumber))"))); + EXPECT_THAT( + [&] { f(Integer(1), Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Root with argument #1 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Root with 0 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Root with 1 argument (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Root with 3 arguments (expected 2)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Root with 4 arguments (expected 2)"))); } TEST(RootTests, exprTest) { diff --git a/tests/src/functions/powers/SqrTests.cpp b/tests/src/functions/powers/SqrTests.cpp index bcffcb2c5..34fa30ab3 100644 --- a/tests/src/functions/powers/SqrTests.cpp +++ b/tests/src/functions/powers/SqrTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/powers/Sqr.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Rational.hpp" #include "fintamath/numbers/Real.hpp" @@ -42,8 +43,27 @@ TEST(SqrTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "a^2"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Sqr with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Sqr with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Sqr with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Sqr with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Sqr with 4 arguments (expected 1)"))); } TEST(SqrTests, exprTest) { diff --git a/tests/src/functions/powers/SqrtTests.cpp b/tests/src/functions/powers/SqrtTests.cpp index a9edf5065..f6d1ba1c9 100644 --- a/tests/src/functions/powers/SqrtTests.cpp +++ b/tests/src/functions/powers/SqrtTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/powers/Sqrt.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Rational.hpp" #include "fintamath/numbers/Real.hpp" @@ -61,8 +62,27 @@ TEST(SqrtTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "sqrt(a)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Sqrt with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Sqrt with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Sqrt with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Sqrt with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Sqrt with 4 arguments (expected 1)"))); } TEST(SqrtTests, exprTest) { diff --git a/tests/src/functions/trigonometry/AcosTests.cpp b/tests/src/functions/trigonometry/AcosTests.cpp index 586161d44..b392bc994 100644 --- a/tests/src/functions/trigonometry/AcosTests.cpp +++ b/tests/src/functions/trigonometry/AcosTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/trigonometry/Acos.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -48,8 +49,27 @@ TEST(AcosTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "acos(a)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Acos with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Acos with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Acos with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Acos with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Acos with 4 arguments (expected 1)"))); } TEST(AcosTests, exprTest) { diff --git a/tests/src/functions/trigonometry/AcotTests.cpp b/tests/src/functions/trigonometry/AcotTests.cpp index dade7662b..07a1abda6 100644 --- a/tests/src/functions/trigonometry/AcotTests.cpp +++ b/tests/src/functions/trigonometry/AcotTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/trigonometry/Acot.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -48,8 +49,27 @@ TEST(AcotTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "acot(a)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Acot with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Acot with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Acot with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Acot with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Acot with 4 arguments (expected 1)"))); } TEST(AcotTests, exprTest) { diff --git a/tests/src/functions/trigonometry/AcscTests.cpp b/tests/src/functions/trigonometry/AcscTests.cpp index c5d9ca09b..f1cdea0f9 100644 --- a/tests/src/functions/trigonometry/AcscTests.cpp +++ b/tests/src/functions/trigonometry/AcscTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/trigonometry/Acsc.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -42,15 +43,33 @@ TEST(AcscTests, callTest) { EXPECT_EQ(f(Rational(1, 10))->toString(), "acsc(1/10)"); EXPECT_EQ(f(Rational(-1, 5))->toString(), "acsc(-1/5)"); - EXPECT_EQ(f(Real("0.5"))->toString(), - "acsc(0.5)"); + EXPECT_EQ(f(Real("0.5"))->toString(), "acsc(0.5)"); EXPECT_EQ(f(Complex(1, 1))->toString(), "acsc(1 + I)"); EXPECT_EQ(f(Variable("a"))->toString(), "acsc(a)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Acsc with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Acsc with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Acsc with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Acsc with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Acsc with 4 arguments (expected 1)"))); } TEST(AcscTests, exprTest) { diff --git a/tests/src/functions/trigonometry/AsecTests.cpp b/tests/src/functions/trigonometry/AsecTests.cpp index 8c0cbab3d..cb67fb1ba 100644 --- a/tests/src/functions/trigonometry/AsecTests.cpp +++ b/tests/src/functions/trigonometry/AsecTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/trigonometry/Asec.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -49,8 +50,27 @@ TEST(AsecTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "asec(a)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Asec with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Asec with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Asec with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Asec with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Asec with 4 arguments (expected 1)"))); } TEST(AsecTests, exprTest) { diff --git a/tests/src/functions/trigonometry/AsinTests.cpp b/tests/src/functions/trigonometry/AsinTests.cpp index 43213ad90..7c8f1acf2 100644 --- a/tests/src/functions/trigonometry/AsinTests.cpp +++ b/tests/src/functions/trigonometry/AsinTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/trigonometry/Asin.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -48,8 +49,27 @@ TEST(AsinTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "asin(a)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Asin with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Asin with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Asin with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Asin with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Asin with 4 arguments (expected 1)"))); } TEST(AsinTests, exprTest) { diff --git a/tests/src/functions/trigonometry/AtanTests.cpp b/tests/src/functions/trigonometry/AtanTests.cpp index 1301ac948..354f41ac4 100644 --- a/tests/src/functions/trigonometry/AtanTests.cpp +++ b/tests/src/functions/trigonometry/AtanTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/trigonometry/Atan.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -48,8 +49,27 @@ TEST(AtanTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "atan(a)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Atan with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Atan with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Atan with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Atan with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Atan with 4 arguments (expected 1)"))); } TEST(AtanTests, exprTest) { diff --git a/tests/src/functions/trigonometry/CosTests.cpp b/tests/src/functions/trigonometry/CosTests.cpp index 2f7749643..8ab100032 100644 --- a/tests/src/functions/trigonometry/CosTests.cpp +++ b/tests/src/functions/trigonometry/CosTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/trigonometry/Cos.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -45,8 +46,27 @@ TEST(CosTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "cos(a)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Cos with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Cos with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Cos with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Cos with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Cos with 4 arguments (expected 1)"))); } TEST(CosTests, exprTest) { diff --git a/tests/src/functions/trigonometry/CotTests.cpp b/tests/src/functions/trigonometry/CotTests.cpp index 10e98f763..98196aad5 100644 --- a/tests/src/functions/trigonometry/CotTests.cpp +++ b/tests/src/functions/trigonometry/CotTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/trigonometry/Cot.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -46,8 +47,27 @@ TEST(CotTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "cot(a)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Cot with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Cot with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Cot with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Cot with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Cot with 4 arguments (expected 1)"))); } TEST(CotTests, exprTest) { diff --git a/tests/src/functions/trigonometry/CscTests.cpp b/tests/src/functions/trigonometry/CscTests.cpp index 5bb542564..49441ccc0 100644 --- a/tests/src/functions/trigonometry/CscTests.cpp +++ b/tests/src/functions/trigonometry/CscTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/trigonometry/Csc.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -45,8 +46,27 @@ TEST(CscTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "csc(a)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Csc with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Csc with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Csc with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Csc with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Csc with 4 arguments (expected 1)"))); } TEST(CscTests, exprTest) { diff --git a/tests/src/functions/trigonometry/SecTests.cpp b/tests/src/functions/trigonometry/SecTests.cpp index 9e3aa5a8d..2f111fcc2 100644 --- a/tests/src/functions/trigonometry/SecTests.cpp +++ b/tests/src/functions/trigonometry/SecTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/trigonometry/Sec.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -45,8 +46,27 @@ TEST(SecTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "sec(a)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Sec with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Sec with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Sec with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Sec with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Sec with 4 arguments (expected 1)"))); } TEST(SecTests, exprTest) { diff --git a/tests/src/functions/trigonometry/SinTests.cpp b/tests/src/functions/trigonometry/SinTests.cpp index bf5dea866..e11326a46 100644 --- a/tests/src/functions/trigonometry/SinTests.cpp +++ b/tests/src/functions/trigonometry/SinTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/trigonometry/Sin.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -45,8 +46,27 @@ TEST(SinTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "sin(a)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Sin with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Sin with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Sin with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Sin with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Sin with 4 arguments (expected 1)"))); } TEST(SinTests, exprTest) { diff --git a/tests/src/functions/trigonometry/TanTests.cpp b/tests/src/functions/trigonometry/TanTests.cpp index be16e5a6f..6ffce83d2 100644 --- a/tests/src/functions/trigonometry/TanTests.cpp +++ b/tests/src/functions/trigonometry/TanTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/functions/trigonometry/Tan.hpp" +#include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Complex.hpp" #include "fintamath/numbers/Rational.hpp" @@ -46,8 +47,27 @@ TEST(TanTests, callTest) { EXPECT_EQ(f(Variable("a"))->toString(), "tan(a)"); - EXPECT_THROW(f(), InvalidInputFunctionException); - EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); + EXPECT_THAT( + [&] { f(Boolean(true)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to call Tan with argument #0 Boolean "True" (expected INumber))"))); + + EXPECT_THAT( + [&] { f(); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Tan with 0 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Tan with 2 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Tan with 3 arguments (expected 1)"))); + EXPECT_THAT( + [&] { f(Integer(1), Integer(2), Integer(3), Integer(4)); }, + testing::ThrowsMessage( + testing::StrEq("Unable to call Tan with 4 arguments (expected 1)"))); } TEST(TanTests, exprTest) { diff --git a/tests/src/literals/BooleanTests.cpp b/tests/src/literals/BooleanTests.cpp index a888038ae..dd4d35790 100644 --- a/tests/src/literals/BooleanTests.cpp +++ b/tests/src/literals/BooleanTests.cpp @@ -1,3 +1,4 @@ +#include #include #include "fintamath/exceptions/InvalidInputException.hpp" @@ -14,12 +15,26 @@ TEST(BooleanTests, stringConstructorTest) { EXPECT_EQ(Boolean("True"), true); EXPECT_EQ(Boolean("False"), false); - EXPECT_THROW(Boolean("true"), InvalidInputException); - EXPECT_THROW(Boolean("false"), InvalidInputException); - EXPECT_THROW(Boolean("10"), InvalidInputException); - EXPECT_THROW(Boolean("i"), InvalidInputException); - EXPECT_THROW(Boolean(""), InvalidInputException); - EXPECT_THROW(Boolean(""), InvalidInputException); + EXPECT_THAT( + [] { Boolean(std::string("")); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Boolean from "" (expected "True" or "False"))"))); + EXPECT_THAT( + [] { Boolean(std::string("true")); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Boolean from "true" (expected "True" or "False"))"))); + EXPECT_THAT( + [] { Boolean(std::string("false")); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Boolean from "false" (expected "True" or "False"))"))); + EXPECT_THAT( + [] { Boolean(std::string("10")); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Boolean from "10" (expected "True" or "False"))"))); + EXPECT_THAT( + [] { Boolean(std::string("i")); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Boolean from "i" (expected "True" or "False"))"))); } TEST(BooleanTests, boolConstructorTest) { diff --git a/tests/src/literals/VariableTests.cpp b/tests/src/literals/VariableTests.cpp index 223af20a2..b1b514813 100644 --- a/tests/src/literals/VariableTests.cpp +++ b/tests/src/literals/VariableTests.cpp @@ -1,3 +1,4 @@ +#include #include #include "fintamath/exceptions/InvalidInputException.hpp" @@ -16,26 +17,91 @@ TEST(VariableTest, stringIntegerConstructorTest) { EXPECT_EQ(Variable("a", 2).toString(), "a_2"); EXPECT_EQ(Variable("a", Integer("100000000000000000000000000000000000000")).toString(), "a_100000000000000000000000000000000000000"); - EXPECT_THROW(Variable(""), InvalidInputException); - EXPECT_THROW(Variable("A"), InvalidInputException); - EXPECT_THROW(Variable("B"), InvalidInputException); - EXPECT_THROW(Variable("C"), InvalidInputException); - EXPECT_THROW(Variable("1"), InvalidInputException); - EXPECT_THROW(Variable("+"), InvalidInputException); - EXPECT_THROW(Variable("!"), InvalidInputException); - EXPECT_THROW(Variable("["), InvalidInputException); - EXPECT_THROW(Variable("|"), InvalidInputException); - EXPECT_THROW(Variable("10"), InvalidInputException); - EXPECT_THROW(Variable("a1"), InvalidInputException); - EXPECT_THROW(Variable("ba"), InvalidInputException); - EXPECT_THROW(Variable("1e"), InvalidInputException); - EXPECT_THROW(Variable("A1"), InvalidInputException); - EXPECT_THROW(Variable("Bb"), InvalidInputException); - EXPECT_THROW(Variable("1C"), InvalidInputException); + EXPECT_THAT( + [] { Variable(""); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Variable name from "" (expected single English lowercase letter))"))); + EXPECT_THAT( + [] { Variable("10"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Variable name from "10" (expected single English lowercase letter))"))); + EXPECT_THAT( + [] { Variable("a1"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Variable name from "a1" (expected single English lowercase letter))"))); + EXPECT_THAT( + [] { Variable("abc"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Variable name from "abc" (expected single English lowercase letter))"))); + EXPECT_THAT( + [] { Variable("1e"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Variable name from "1e" (expected single English lowercase letter))"))); + EXPECT_THAT( + [] { Variable("A1"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Variable name from "A1" (expected single English lowercase letter))"))); + EXPECT_THAT( + [] { Variable("Bb"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Variable name from "Bb" (expected single English lowercase letter))"))); + EXPECT_THAT( + [] { Variable("1C"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Variable name from "1C" (expected single English lowercase letter))"))); + EXPECT_THAT( + [] { Variable("A"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Variable name from "A" (expected single English lowercase letter))"))); + EXPECT_THAT( + [] { Variable("B"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Variable name from "B" (expected single English lowercase letter))"))); + EXPECT_THAT( + [] { Variable("C"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Variable name from "C" (expected single English lowercase letter))"))); + EXPECT_THAT( + [] { Variable("1"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Variable name from "1" (expected single English lowercase letter))"))); + EXPECT_THAT( + [] { Variable("+"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Variable name from "+" (expected single English lowercase letter))"))); + EXPECT_THAT( + [] { Variable("!"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Variable name from "!" (expected single English lowercase letter))"))); + EXPECT_THAT( + [] { Variable("["); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Variable name from "[" (expected single English lowercase letter))"))); + EXPECT_THAT( + [] { Variable("|"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Variable name from "|" (expected single English lowercase letter))"))); - EXPECT_THROW(Variable("a", -1), InvalidInputException); - EXPECT_THROW(Variable("a", -2), InvalidInputException); - EXPECT_THROW(Variable("a", Integer("-100000000000000000000000000000000000000")), InvalidInputException); + EXPECT_THAT( + [] { Variable("ab", 1); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Variable name from "ab" (expected single English lowercase letter))"))); + EXPECT_THAT( + [] { Variable("A", 1); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Variable name from "A" (expected single English lowercase letter))"))); + EXPECT_THAT( + [] { Variable("a", -1); }, + testing::ThrowsMessage( + testing::StrEq(R"(Negative Variable index "-1" is not allowed)"))); + EXPECT_THAT( + [] { Variable("a", -2); }, + testing::ThrowsMessage( + testing::StrEq(R"(Negative Variable index "-2" is not allowed)"))); + EXPECT_THAT( + [] { Variable("a", Integer("-100000000000000000000000000000000000000")); }, + testing::ThrowsMessage( + testing::StrEq(R"(Negative Variable index "-100000000000000000000000000000000000000" is not allowed)"))); } TEST(VariableTest, getClassTest) { diff --git a/tests/src/numbers/ComplexTests.cpp b/tests/src/numbers/ComplexTests.cpp index 412148a51..486ce0127 100644 --- a/tests/src/numbers/ComplexTests.cpp +++ b/tests/src/numbers/ComplexTests.cpp @@ -1,3 +1,4 @@ +#include #include #include "fintamath/exceptions/InvalidInputException.hpp" @@ -54,25 +55,82 @@ TEST(ComplexTests, stringConstructorTest) { EXPECT_EQ(Complex(".1I").toString(), "1/10 I"); EXPECT_EQ(Complex("1.I").toString(), "I"); - EXPECT_THROW(Complex("--10"), InvalidInputException); - EXPECT_THROW(Complex("test"), InvalidInputException); - EXPECT_THROW(Complex(""), InvalidInputException); - EXPECT_THROW(Complex("+"), InvalidInputException); - EXPECT_THROW(Complex("939849.0-0023"), InvalidInputException); - EXPECT_THROW(Complex("a"), InvalidInputException); - EXPECT_THROW(Complex("a.1"), InvalidInputException); - EXPECT_THROW(Complex("1.a"), InvalidInputException); - EXPECT_THROW(Complex("1a.1"), InvalidInputException); - EXPECT_THROW(Complex("1.1a"), InvalidInputException); - EXPECT_THROW(Complex(".1."), InvalidInputException); - EXPECT_THROW(Complex("."), InvalidInputException); - EXPECT_THROW(Complex("--10.-1"), InvalidInputException); - EXPECT_THROW(Complex("10.-1"), InvalidInputException); - EXPECT_THROW(Complex("1-0.1"), InvalidInputException); - EXPECT_THROW(Complex("10-.1"), InvalidInputException); - EXPECT_THROW(Complex("10.--1"), InvalidInputException); - EXPECT_THROW(Complex("1.10.1"), InvalidInputException); - EXPECT_THROW(Complex("0II"), InvalidInputException); + EXPECT_THAT( + [] { Complex(""); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Complex from "")"))); + EXPECT_THAT( + [] { Complex("--10"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Complex from "--10")"))); + EXPECT_THAT( + [] { Complex("test"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Complex from "test")"))); + EXPECT_THAT( + [] { Complex("+"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Complex from "+")"))); + EXPECT_THAT( + [] { Complex("939849.0-0023"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Complex from "939849.0-0023")"))); + EXPECT_THAT( + [] { Complex("a"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Complex from "a")"))); + EXPECT_THAT( + [] { Complex("a.1"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Complex from "a.1")"))); + EXPECT_THAT( + [] { Complex("1.a"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Complex from "1.a")"))); + EXPECT_THAT( + [] { Complex("1a.1"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Complex from "1a.1")"))); + EXPECT_THAT( + [] { Complex("1.1a"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Complex from "1.1a")"))); + EXPECT_THAT( + [] { Complex(".1."); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Complex from ".1.")"))); + EXPECT_THAT( + [] { Complex("."); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Complex from ".")"))); + EXPECT_THAT( + [] { Complex("--10.-1"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Complex from "--10.-1")"))); + EXPECT_THAT( + [] { Complex("10.-1"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Complex from "10.-1")"))); + EXPECT_THAT( + [] { Complex("1-0.1"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Complex from "1-0.1")"))); + EXPECT_THAT( + [] { Complex("10-.1"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Complex from "10-.1")"))); + EXPECT_THAT( + [] { Complex("10.--1"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Complex from "10.--1")"))); + EXPECT_THAT( + [] { Complex("1.10.1"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Complex from "1.10.1")"))); + EXPECT_THAT( + [] { Complex("0II"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Complex from "0II")"))); } TEST(ComplexTests, intIntConstructorTest) { @@ -105,13 +163,34 @@ TEST(ComplexTests, numberNumberConstructorTest) { EXPECT_EQ(Complex(Real("2.2"), Rational(2, 3)).toString(), "2.2 + 2/3 I"); EXPECT_EQ(Complex(Rational(3, 2), Real("2.2")).toString(), "3/2 + 2.2 I"); - EXPECT_THROW(Complex(Complex(), Complex()), InvalidInputException); - EXPECT_THROW(Complex(Complex(), Integer()), InvalidInputException); - EXPECT_THROW(Complex(Integer(), Complex()), InvalidInputException); - EXPECT_THROW(Complex(Complex(), Rational()), InvalidInputException); - EXPECT_THROW(Complex(Rational(), Complex()), InvalidInputException); - EXPECT_THROW(Complex(Complex(), Real()), InvalidInputException); - EXPECT_THROW(Complex(Real(), Complex()), InvalidInputException); + EXPECT_THAT( + [] { Complex(Complex(), Complex()); }, + testing::ThrowsMessage( + testing::StrEq("Nested Complex numbers are not allowed"))); + EXPECT_THAT( + [] { Complex(Complex(), Integer()); }, + testing::ThrowsMessage( + testing::StrEq("Nested Complex numbers are not allowed"))); + EXPECT_THAT( + [] { Complex(Integer(), Complex()); }, + testing::ThrowsMessage( + testing::StrEq("Nested Complex numbers are not allowed"))); + EXPECT_THAT( + [] { Complex(Complex(), Rational()); }, + testing::ThrowsMessage( + testing::StrEq("Nested Complex numbers are not allowed"))); + EXPECT_THAT( + [] { Complex(Rational(), Complex()); }, + testing::ThrowsMessage( + testing::StrEq("Nested Complex numbers are not allowed"))); + EXPECT_THAT( + [] { Complex(Complex(), Real()); }, + testing::ThrowsMessage( + testing::StrEq("Nested Complex numbers are not allowed"))); + EXPECT_THAT( + [] { Complex(Real(), Complex()); }, + testing::ThrowsMessage( + testing::StrEq("Nested Complex numbers are not allowed"))); } TEST(ComplexTests, integerConstructorTest) { @@ -441,8 +520,14 @@ TEST(ComplexTests, divideAssignmentOperatorTest) { EXPECT_EQ(Complex(-738, 10) /= Complex(5, 2), Complex(Rational(-3670, 29), Rational(1526, 29))); EXPECT_EQ(Complex(-738, 10) /= Complex(-5, 2), Complex(Rational(3710, 29), Rational(1426, 29))); - EXPECT_THROW(Complex(0, 0) /= Complex(0, 0), UndefinedException); - EXPECT_THROW(Complex(2, 3) /= Complex(0, 0), UndefinedException); + EXPECT_THAT( + [] { Complex(0, 0) /= Complex(0, 0); }, + testing::ThrowsMessage( + testing::StrEq(R"(Undefined "0" / "0" (division by zero))"))); + EXPECT_THAT( + [] { Complex(2, 3) /= Complex(0, 0); }, + testing::ThrowsMessage( + testing::StrEq(R"(Undefined "2 + 3 I" / "0" (division by zero))"))); } TEST(ComplexTests, integerDivideAssignmentOperatorTest) { diff --git a/tests/src/numbers/IntegerFunctionsTests.cpp b/tests/src/numbers/IntegerFunctionsTests.cpp index 8767d4a0e..c69501f04 100644 --- a/tests/src/numbers/IntegerFunctionsTests.cpp +++ b/tests/src/numbers/IntegerFunctionsTests.cpp @@ -1,3 +1,4 @@ +#include #include #include "fintamath/numbers/Complex.hpp" @@ -83,7 +84,10 @@ TEST(IntegerFunctionsTests, sqrtTest) { EXPECT_EQ(sqrt(Integer("992188888888")), Integer(996086)); EXPECT_EQ(sqrt(Integer("68732648273642987365932706179432649827364")), Integer("262169121510606178721")); - EXPECT_THROW(sqrt(Integer(-9289)), UndefinedFunctionException); + EXPECT_THAT( + [] { sqrt(Integer(-9289)); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); } TEST(IntegerFunctionsTests, sqrtWithRemainderTest) { @@ -113,7 +117,10 @@ TEST(IntegerFunctionsTests, sqrtWithRemainderTest) { EXPECT_EQ(sqrt(Integer("68732648273642987365932706179432649827364"), remainder), Integer("262169121510606178721")); EXPECT_EQ(remainder.toString(), "307087949370856631523"); - EXPECT_THROW(sqrt(Integer(-9289), remainder), UndefinedFunctionException); + EXPECT_THAT( + [&] { sqrt(Integer(-9289), remainder); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); } TEST(IntegerFunctionsTests, powTest) { @@ -163,10 +170,22 @@ TEST(IntegerFunctionsTests, powTest) { EXPECT_EQ(pow(Complex(6789, 11), Integer(-4)).toString(), "531075666086959/1128212841481282934557153710724 - 860496245400/282053210370320733639288427681 I"); - EXPECT_THROW(pow(Integer(0), Integer(0)), UndefinedBinaryOperatorException); - EXPECT_THROW(pow(Rational(0), Integer(0)), UndefinedBinaryOperatorException); - EXPECT_THROW(pow(Real(0), Integer(0)), UndefinedBinaryOperatorException); - EXPECT_THROW(pow(Complex(0), Integer(0)), UndefinedBinaryOperatorException); + EXPECT_THAT( + [] { pow(Integer(0), Integer(0)); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { pow(Rational(0), Integer(0)); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { pow(Real(0), Integer(0)); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { pow(Complex(0), Integer(0)); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); } TEST(IntegerFunctionsTests, factorialTest) { @@ -179,8 +198,14 @@ TEST(IntegerFunctionsTests, factorialTest) { EXPECT_EQ(factorial(Integer(10)), 3628800); EXPECT_EQ(factorial(Integer(25)).toString(), "15511210043330985984000000"); - EXPECT_THROW(factorial(Integer(-1)), UndefinedUnaryOperatorException); - EXPECT_THROW(factorial(Integer(-2)), UndefinedUnaryOperatorException); + EXPECT_THAT( + [] { factorial(Integer(-1)); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { factorial(Integer(-2)); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); } TEST(IntegerFunctionsTests, nthFactorialTest) { @@ -220,10 +245,22 @@ TEST(IntegerFunctionsTests, nthFactorialTest) { EXPECT_EQ(factorial(Integer(10), 10), 10); EXPECT_EQ(factorial(Integer(25), 10).toString(), "1875"); - EXPECT_THROW(factorial(Integer(-1), 1), UndefinedUnaryOperatorException); - EXPECT_THROW(factorial(Integer(-1), 20), UndefinedUnaryOperatorException); - EXPECT_THROW(factorial(Integer(-2), 1), UndefinedUnaryOperatorException); - EXPECT_THROW(factorial(Integer(-2), 20), UndefinedUnaryOperatorException); + EXPECT_THAT( + [] { factorial(Integer(-1), 1); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { factorial(Integer(-1), 20); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { factorial(Integer(-2), 1); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { factorial(Integer(-2), 20); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); } TEST(IntegerFunctionsTests, factorsTest) { @@ -269,9 +306,18 @@ TEST(IntegerFunctionsTests, factorsTest) { EXPECT_EQ(factorToCountMap[59], 1); EXPECT_EQ(factorToCountMap[Integer("7406060776921378681")], 1); - EXPECT_THROW(factors(-1), UndefinedFunctionException); - EXPECT_THROW(factors(0), UndefinedFunctionException); - EXPECT_THROW(factors(1), UndefinedFunctionException); + EXPECT_THAT( + [] { factors(-1); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { factors(0); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { factors(1); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); } TEST(IntegerFunctionsTests, combinationsTest) { @@ -279,9 +325,18 @@ TEST(IntegerFunctionsTests, combinationsTest) { EXPECT_EQ(combinations(Integer(10), Integer(7)), 120); EXPECT_EQ(combinations(Integer(15), Integer(2)), 105); - EXPECT_THROW(combinations(Integer(20), Integer(40)), UndefinedFunctionException); - EXPECT_THROW(combinations(Integer(-3), Integer(-8)), UndefinedUnaryOperatorException); - EXPECT_THROW(combinations(Integer(5), Integer(-3)), UndefinedUnaryOperatorException); + EXPECT_THAT( + [] { combinations(Integer(20), Integer(40)); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { combinations(Integer(-3), Integer(-8)); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { combinations(Integer(5), Integer(-3)); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); } TEST(IntegerFunctionsTests, multinomialCoefficientTest) { @@ -290,9 +345,24 @@ TEST(IntegerFunctionsTests, multinomialCoefficientTest) { EXPECT_EQ(multinomialCoefficient(Integer(5), {Integer(3), Integer(2)}), 10); EXPECT_EQ(multinomialCoefficient(Integer(12), {Integer(3), Integer(9), Integer(0)}), 220); - EXPECT_THROW(multinomialCoefficient(Integer(12), {Integer(3)}), UndefinedFunctionException); - EXPECT_THROW(multinomialCoefficient(Integer(12), {Integer(3), Integer(19), Integer(0)}), UndefinedFunctionException); - EXPECT_THROW(multinomialCoefficient(Integer(12), {Integer(0)}), UndefinedFunctionException); - EXPECT_THROW(multinomialCoefficient(Integer(-12), {Integer(3), Integer(9), Integer(0)}), UndefinedFunctionException); - EXPECT_THROW(multinomialCoefficient(Integer(12), {Integer(-3), Integer(9), Integer(0)}), UndefinedFunctionException); + EXPECT_THAT( + [] { multinomialCoefficient(Integer(12), {Integer(3)}); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { multinomialCoefficient(Integer(12), {Integer(3), Integer(19), Integer(0)}); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { multinomialCoefficient(Integer(12), {Integer(0)}); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { multinomialCoefficient(Integer(-12), {Integer(3), Integer(9), Integer(0)}); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { multinomialCoefficient(Integer(12), {Integer(-3), Integer(9), Integer(0)}); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); } diff --git a/tests/src/numbers/IntegerTests.cpp b/tests/src/numbers/IntegerTests.cpp index 5fedad20f..d10b0b77f 100644 --- a/tests/src/numbers/IntegerTests.cpp +++ b/tests/src/numbers/IntegerTests.cpp @@ -1,3 +1,4 @@ +#include #include #include "fintamath/numbers/Integer.hpp" @@ -23,10 +24,22 @@ TEST(IntegerTests, stringConstructorTest) { EXPECT_EQ(Integer("00"), 0); EXPECT_EQ(Integer("-00"), 0); - EXPECT_THROW(Integer("--10"), InvalidInputException); - EXPECT_THROW(Integer("test"), InvalidInputException); - EXPECT_THROW(Integer(""), InvalidInputException); - EXPECT_THROW(Integer("+"), InvalidInputException); + EXPECT_THAT( + [] { Integer(""); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Integer from "")"))); + EXPECT_THAT( + [] { Integer("--10"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Integer from "--10")"))); + EXPECT_THAT( + [] { Integer("test"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Integer from "test")"))); + EXPECT_THAT( + [] { Integer("+"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Integer from "+")"))); } TEST(IntegerTests, templateConstructorTest) { @@ -190,7 +203,10 @@ TEST(IntegerTests, divideAssignmentOperatorTest) { Integer("3507630615696849555869044818661735064986392883263011691538871248141434862220387449579227548346015035603501276296494442204769872208628882685816583149015034150490829747567986311156822048603845157334656209386816063095043939468216080230001796494390400252142375053346581510773088042280290835395905258970276127578670424725237113115641881479792031434427596080908227551489188776476145554883257759405245297150541759841671819727944845899493678892840111830112509529920517471699237861267263602427655073892668208557712684031475765670957010740054698088570050264362373595571625821629034477445434265168041405756975664327860057312868835959178663661834688407715795207372052181069795781487373087361"), Integer("3507630615696849555869044818661735064986392883263011691538871248141434862220387449579227548346015035603501276296494442204769872208628882685816583149015034150490829747567986311156822048603845157334656209386816063095043939468216080230001796494390400252142375053346581510773088042280290835395905258970276127578670424725237113115641881479792031434427596080908227551489188776476145554883257759405245297150541759841671819727944845899493678892840111830112509529920517471699237861267263602427655073892668208557712684031475765670957010740054698088570050264362373595571625821629034477445434265168041405756975664327860057312868835959178663661834688407715795207372052181069795781487373087361")); - EXPECT_THROW(Integer(-25) /= Integer(0), UndefinedBinaryOperatorException); + EXPECT_THAT( + [] { Integer(-25) /= Integer(0); }, + testing::ThrowsMessage( + testing::StrEq(R"(Undefined "-25" / "0" (division by zero))"))); } TEST(IntegerTests, intDivideAssignmentOperatorTest) { @@ -252,7 +268,10 @@ TEST(IntegerTests, moduloAssignmentOperatorTest) { EXPECT_EQ(Integer("5473289765787324752874728729473876573874654738747632794676328746738849389483948938493848394839849383893847267328724673874") %= Integer("1738383928837528673287446238746237943"), Integer("1186817955126284001426922341829394317")); - EXPECT_THROW(Integer(-25) %= Integer(0), UndefinedBinaryOperatorException); + EXPECT_THAT( + [] { Integer(-25) %= Integer(0); }, + testing::ThrowsMessage( + testing::StrEq(R"(Undefined "-25" % "0" (modulo by zero))"))); } TEST(IntegerTests, intModuloAssignmentOperatorTest) { @@ -362,8 +381,14 @@ TEST(IntegerTests, bitLeftShiftAssignmentOperatorTest) { EXPECT_EQ(Integer("12091392839827399999999999999999999992983729837928392800000711") <<= 5, Integer("386924570874476799999999999999999999775479354813708569600022752")); - EXPECT_THROW(Integer(192) <<= Integer(-5), UndefinedBinaryOperatorException); - EXPECT_THROW(Integer(-192) <<= Integer(-5), UndefinedBinaryOperatorException); + EXPECT_THAT( + [] { Integer(192) <<= Integer(-5); }, + testing::ThrowsMessage( + testing::StrEq(R"(Undefined "192" << "-5" (negative shift))"))); + EXPECT_THAT( + [] { Integer(-192) <<= Integer(-5); }, + testing::ThrowsMessage( + testing::StrEq(R"(Undefined "-192" << "-5" (negative shift))"))); } TEST(IntegerTests, intBitLeftShiftAssignmentOperatorTest) { @@ -389,8 +414,14 @@ TEST(IntegerTests, bitRightShiftAssignmentOperatorTest) { EXPECT_EQ(Integer("12091392839827399999999999999999999992983729837928392800000711") >>= 5, Integer("377856026244606249999999999999999999780741557435262275000022")); - EXPECT_THROW(Integer(192) >>= Integer(-5), UndefinedBinaryOperatorException); - EXPECT_THROW(Integer(-192) >>= Integer(-5), UndefinedBinaryOperatorException); + EXPECT_THAT( + [] { Integer(192) >>= Integer(-5); }, + testing::ThrowsMessage( + testing::StrEq(R"(Undefined "192" >> "-5" (negative shift))"))); + EXPECT_THAT( + [] { Integer(-192) >>= Integer(-5); }, + testing::ThrowsMessage( + testing::StrEq(R"(Undefined "-192" >> "-5" (negative shift))"))); } TEST(IntegerTests, intBitRightShiftAssignmentOperatorTest) { diff --git a/tests/src/numbers/NumberAbstractTests.cpp b/tests/src/numbers/NumberAbstractTests.cpp index c3fa499e0..2175f07dd 100644 --- a/tests/src/numbers/NumberAbstractTests.cpp +++ b/tests/src/numbers/NumberAbstractTests.cpp @@ -1,3 +1,4 @@ +#include #include #include "fintamath/exceptions/UndefinedException.hpp" @@ -17,8 +18,14 @@ TEST(NumberAbstractIntegerTests, divideTest) { EXPECT_EQ((Integer(0) / cast(Real(2)))->toString(), "0"); EXPECT_EQ((Integer(1) / cast(Real(2)))->toString(), "0.5"); - EXPECT_THROW((Integer(0) / cast(Integer(0)))->toString(), UndefinedException); - EXPECT_THROW((Integer(0) / cast(Real(0)))->toString(), UndefinedException); + EXPECT_THAT( + [] { Integer(0) / cast(Integer(0)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Undefined "0" / "0" (division by zero))"))); + EXPECT_THAT( + [] { Integer(0) / cast(Real(0)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Undefined "0.0" / "0.0" (division by zero))"))); } //-------------------------------------------------------------------------------------// @@ -32,8 +39,14 @@ TEST(NumberAbstractRationalTests, divideTest) { EXPECT_EQ((Rational(0) / cast(Real(2)))->toString(), "0"); EXPECT_EQ((Rational(1) / cast(Real(2)))->toString(), "0.5"); - EXPECT_THROW((Rational(0) / cast(Integer(0)))->toString(), UndefinedException); - EXPECT_THROW((Rational(0) / cast(Real(0)))->toString(), UndefinedException); + EXPECT_THAT( + [] { Rational(0) / cast(Integer(0)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Undefined "0" / "0" (division by zero))"))); + EXPECT_THAT( + [] { Rational(0) / cast(Real(0)); }, + testing::ThrowsMessage( + testing::StrEq(R"(Undefined "0.0" / "0.0" (division by zero))"))); } //-------------------------------------------------------------------------------------// diff --git a/tests/src/numbers/RationalTests.cpp b/tests/src/numbers/RationalTests.cpp index 02ce09cb7..bae82967a 100644 --- a/tests/src/numbers/RationalTests.cpp +++ b/tests/src/numbers/RationalTests.cpp @@ -1,3 +1,4 @@ +#include #include #include @@ -21,24 +22,78 @@ TEST(RationalTests, stringConstructorTest) { EXPECT_EQ(Rational(".1").toString(), "1/10"); EXPECT_EQ(Rational("1.").toString(), "1"); - EXPECT_THROW(Rational("--10"), InvalidInputException); - EXPECT_THROW(Rational("test"), InvalidInputException); - EXPECT_THROW(Rational(""), InvalidInputException); - EXPECT_THROW(Rational("+"), InvalidInputException); - EXPECT_THROW(Rational("939849.0-0023"), InvalidInputException); - EXPECT_THROW(Rational("a"), InvalidInputException); - EXPECT_THROW(Rational("a.1"), InvalidInputException); - EXPECT_THROW(Rational("1.a"), InvalidInputException); - EXPECT_THROW(Rational("1a.1"), InvalidInputException); - EXPECT_THROW(Rational("1.1a"), InvalidInputException); - EXPECT_THROW(Rational(".1."), InvalidInputException); - EXPECT_THROW(Rational("."), InvalidInputException); - EXPECT_THROW(Rational("--10.-1"), InvalidInputException); - EXPECT_THROW(Rational("10.-1"), InvalidInputException); - EXPECT_THROW(Rational("1-0.1"), InvalidInputException); - EXPECT_THROW(Rational("10-.1"), InvalidInputException); - EXPECT_THROW(Rational("10.--1"), InvalidInputException); - EXPECT_THROW(Rational("1.10.1"), InvalidInputException); + EXPECT_THAT( + [] { Rational(""); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Rational from "")"))); + EXPECT_THAT( + [] { Rational("--10"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Rational from "--10")"))); + EXPECT_THAT( + [] { Rational("test"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Rational from "test")"))); + EXPECT_THAT( + [] { Rational("+"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Rational from "+")"))); + EXPECT_THAT( + [] { Rational("939849.0-0023"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Rational from "939849.0-0023")"))); + EXPECT_THAT( + [] { Rational("a"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Rational from "a")"))); + EXPECT_THAT( + [] { Rational("."); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Rational from ".")"))); + EXPECT_THAT( + [] { Rational("a.1"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Rational from "a.1")"))); + EXPECT_THAT( + [] { Rational("1.a"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Rational from "1.a")"))); + EXPECT_THAT( + [] { Rational("1a.1"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Rational from "1a.1")"))); + EXPECT_THAT( + [] { Rational("1.1a"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Rational from "1.1a")"))); + EXPECT_THAT( + [] { Rational(".1."); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Rational from ".1.")"))); + EXPECT_THAT( + [] { Rational("--10.-1"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Rational from "--10.-1")"))); + EXPECT_THAT( + [] { Rational("10.-1"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Rational from "10.-1")"))); + EXPECT_THAT( + [] { Rational("1-0.1"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Rational from "1-0.1")"))); + EXPECT_THAT( + [] { Rational("10-.1"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Rational from "10-.1")"))); + EXPECT_THAT( + [] { Rational("10.--1"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Rational from "10.--1")"))); + EXPECT_THAT( + [] { Rational("1.10.1"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Rational from "1.10.1")"))); } TEST(RationalTests, integerIntegerConstructorTest) { @@ -46,7 +101,10 @@ TEST(RationalTests, integerIntegerConstructorTest) { EXPECT_EQ(Rational(2849300, 18493).toString(), "2849300/18493"); EXPECT_EQ(Rational(2849300, -1893).toString(), "-2849300/1893"); - EXPECT_THROW(Rational(23070, 0), UndefinedBinaryOperatorException); + EXPECT_THAT( + [] { Rational(23070, 0); }, + testing::ThrowsMessage( + testing::StrEq(R"(Undefined "23070" / "0" (division by zero))"))); } TEST(RationalTests, integerConstructorTest) { @@ -212,7 +270,10 @@ TEST(RationalTests, divideAssignmentOperatorTest) { EXPECT_EQ(Rational(738, 10) /= Rational(5, 2), Rational(738, 25)); EXPECT_EQ(Rational(-738, 10) /= Rational(-5, 2), Rational(738, 25)); - EXPECT_THROW(Rational(-738, -10) /= Rational("0"), UndefinedBinaryOperatorException); + EXPECT_THAT( + [] { Rational(-738, -10) /= Rational("0"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Undefined "369/5" / "0" (division by zero))"))); } TEST(RationalTests, integerDivideAssignmentOperatorTest) { diff --git a/tests/src/numbers/RealFunctionsTests.cpp b/tests/src/numbers/RealFunctionsTests.cpp index cdc4be8d0..893317c8d 100644 --- a/tests/src/numbers/RealFunctionsTests.cpp +++ b/tests/src/numbers/RealFunctionsTests.cpp @@ -1,3 +1,4 @@ +#include #include #include "fintamath/core/Cache.hpp" @@ -93,10 +94,14 @@ TEST(RealFunctionsTests, floorTest) { EXPECT_EQ(floor(-1 - 1 / getBottom()).toString(), "-2"); - EXPECT_THROW(floor(getTop()), - UndefinedFunctionException); - EXPECT_THROW(floor(-getTop()), - UndefinedFunctionException); + EXPECT_THAT( + [] { floor(getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { floor(-getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(floor(1 / getTop()).toString(), "0"); EXPECT_EQ(floor(-1 / getTop()).toString(), @@ -170,10 +175,14 @@ TEST(RealFunctionsTests, ceilTest) { EXPECT_EQ(ceil(-1 - 1 / getBottom()).toString(), "-1"); - EXPECT_THROW(ceil(getTop()), - UndefinedFunctionException); - EXPECT_THROW(ceil(-getTop()), - UndefinedFunctionException); + EXPECT_THAT( + [] { ceil(getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { ceil(-getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(ceil(1 / getTop()).toString(), "1"); EXPECT_EQ(ceil(-1 / getTop()).toString(), @@ -263,46 +272,68 @@ TEST(RealFunctionsTests, sqrtTest) { EXPECT_EQ(sqrt(Real("23525.32323")).toString(), "153.3796701978459725492204121512750781434647796772676747984731910025774620380353585873562153282468402449005481841073883419559395475898767906139439557306692737624706612235430876655932097400345746485358772717813443198131631030112210968228863289213224144876095410020617778466774885899344482470787465483347525492641579485905056875560330297592329863862879918845030254813451236241418098342383111584169389597987963419936486843277917396618643781613363643398613256282148482430926660270155657970283248756900848"); - EXPECT_THROW(sqrt(Real("-0")), - UndefinedFunctionException); - EXPECT_THROW(sqrt(Real(-1)), - UndefinedFunctionException); - EXPECT_THROW(sqrt(Real(-10)), - UndefinedFunctionException); + EXPECT_THAT( + [] { sqrt(Real("-0")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { sqrt(Real(-1)); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { sqrt(Real(-10)); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(sqrt(getBottom()).toString(), "7787033741169900729251715815485773693572833921585377451230548885066769607873479007659071982456633322947892066185977166857642583972097125178340595060116728563374256202600009698063524254105227036090331595060371028923930614245952174706617222746879926470.8510897821851530612877059206724864583284715928797081352754008253316368153779308877986149769954082553680155667453706957387521573664658902203158531980680861391512633677953799840216307772389412518628573193107066033055571314455053475570689817047532784603"); - EXPECT_THROW(sqrt(-getBottom()), - UndefinedFunctionException); + EXPECT_THAT( + [] { sqrt(-getBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(sqrt(1 / getBottom()).toString(), "1.2841860369925185169195865952383508057123821807667332113965732899333735192964417864608252585218328774917153021280599859509786581786949635487347411625376722695975048418146219841266294120347267333021747448367685684705244150436777244265866727495790653942061720429576784243367046100069815963928689537008542761364333764862880204579607209976819485622074126185896863972614464760124406252414731669354556859013861276802795992857774887556800764918992498834454139271858853705219677109320158415550275924857185617*10^-250"); - EXPECT_THROW(sqrt(-1 / getBottom()), - UndefinedFunctionException); + EXPECT_THAT( + [] { sqrt(-1 / getBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(sqrt(1 + 1 / getBottom()).toString(), "1.0"); EXPECT_EQ(sqrt(1 - 1 / getBottom()).toString(), "0.99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"); - EXPECT_THROW(sqrt(-1 + 1 / getBottom()), - UndefinedFunctionException); - EXPECT_THROW(sqrt(-1 - 1 / getBottom()), - UndefinedFunctionException); + EXPECT_THAT( + [] { sqrt(-1 + 1 / getBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { sqrt(-1 - 1 / getBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(sqrt(getTop()).toString(), "12838650304502567820342847439865633074310503792406078718470723550586214728557638663815746712937333587127496004640597516330302267248830820742443565086264610567153748278274474007832355643130116977702031439768479199109529814956630304548763269465384389756.52053975223085046502607341722170036312711000508017122016275623179708765814713563176019216943962531158532833134883846404994409109602478985370587448336374563571387052781900218402134345188878655222048458591611141484862841724667172384676656109304785616"); - EXPECT_THROW(sqrt(-getTop()), - UndefinedFunctionException); + EXPECT_THAT( + [] { sqrt(-getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(sqrt(1 / getTop()).toString(), "7.7889807439439008591929713981619621881971392435573811385088347637072345211810942977255979201531668508482901835644432798800170069487225436142800834442509986034840508694607108858414951348906886898011055367223021346068786307215243194670694502011075788038186003443520210828144735797247891719537311773034898064286211749687166104322818682124309519595250930225768952588266953614018071794569009012215771558628143915625887558527587041384073595362951663610913990606444790659372759934196101320638736883335585609*10^-251"); - EXPECT_THROW(sqrt(-1 / getTop()), - UndefinedFunctionException); + EXPECT_THAT( + [] { sqrt(-1 / getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(sqrt(1 + 1 / getTop()).toString(), "1.0"); EXPECT_EQ(sqrt(1 - 1 / getTop()).toString(), "1.0"); - EXPECT_THROW(sqrt(-1 + 1 / getTop()), - UndefinedFunctionException); - EXPECT_THROW(sqrt(-1 - 1 / getTop()), - UndefinedFunctionException); + EXPECT_THAT( + [] { sqrt(-1 + 1 / getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { sqrt(-1 - 1 / getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); } TEST(RealFunctionsTests, powTest) { @@ -360,25 +391,43 @@ TEST(RealFunctionsTests, powTest) { EXPECT_EQ(pow(Real("10"), 1 / Real("-10000")).toString(), "0.99976976799815658635141604638981297541396466984477711459083930684685186989697929041213306336963649014516445226715342205456445791603567419530668529333352385821493766355725683790126843515237328825664519963335505490416683633603244426616970444670188624455993900745976147392132159517393443913064196380170053772066058092785778167974295533857824628460101843381416143605938274800210123785374166454561558791202253353388499943904479146244325732868900825077422806602517570895866818404904976261773431671253269019"); - EXPECT_THROW(pow(Real("0"), Real("0")), - UndefinedBinaryOperatorException); - EXPECT_THROW(pow(Real("0"), Real("-0")), - UndefinedBinaryOperatorException); - EXPECT_THROW(pow(Real("-0"), Real("0")), - UndefinedBinaryOperatorException); - EXPECT_THROW(pow(Real("-0"), Real("-0")), - UndefinedBinaryOperatorException); - EXPECT_THROW(pow(Real("0"), Real("-10")), - UndefinedBinaryOperatorException); - EXPECT_THROW(pow(Real("-10"), Real("1.5")), - UndefinedBinaryOperatorException); - EXPECT_THROW(pow(Real("-0"), Real("1.5")), - UndefinedBinaryOperatorException); - EXPECT_THROW(pow(Real("10"), Real("100000000000000000000")), - UndefinedBinaryOperatorException); - - EXPECT_THROW(pow(2, getBottom()), - UndefinedBinaryOperatorException); + EXPECT_THAT( + [] { pow(Real("0"), Real("0")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { pow(Real("0"), Real("-0")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { pow(Real("-0"), Real("0")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { pow(Real("-0"), Real("-0")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { pow(Real("0"), Real("-10")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { pow(Real("-10"), Real("1.5")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { pow(Real("-0"), Real("1.5")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { pow(Real("10"), Real("100000000000000000000")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + + EXPECT_THAT( + [] { pow(2, getBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(pow(2, -getBottom()).toString(), "0.0"); EXPECT_EQ(pow(2, 1 / getBottom()).toString(), @@ -394,8 +443,10 @@ TEST(RealFunctionsTests, powTest) { EXPECT_EQ(pow(2, -1 - 1 / getBottom()).toString(), "0.49999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"); - EXPECT_THROW(pow(2, getTop()), - UndefinedBinaryOperatorException); + EXPECT_THAT( + [] { pow(2, getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(pow(2, -getTop()).toString(), "0.0"); EXPECT_EQ(pow(2, 1 / getTop()).toString(), @@ -430,8 +481,10 @@ TEST(RealFunctionsTests, expTest) { EXPECT_EQ(exp(Real("-10")).toString(), "4.5399929762484851535591515560550610237918088866564969259071305650999421614302281652525004545947782321708055089686028492945199117244520388837183347709414567560990909217007363970181059501783900762968517787030908824365171548448722293652332416020501168264360305604941570107729975354408079403994232932138270780520042710498960354486166066837009201707573208836344679390514026888603880832944976776162030390901503245487645114316303309520493125377657667740067564548767381252875056905722753776283821712841436637*10^-5"); - EXPECT_THROW(exp(getBottom()), - UndefinedFunctionException); + EXPECT_THAT( + [] { exp(getBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(exp(-getBottom()).toString(), "0.0"); EXPECT_EQ(exp(1 / getBottom()).toString(), @@ -447,8 +500,10 @@ TEST(RealFunctionsTests, expTest) { EXPECT_EQ(exp(-1 - 1 / getBottom()).toString(), "0.36787944117144232159552377016146086744581113103176783450783680169746149574489980335714727434591964374662732527684399520824697579279012900862665358949409878309219436737733811504863899112514561634498771997868447595793974730254989249545323936620796481051464752061229422308916492656660036507457728370553285373838810680478761195682989345449735073931859921661743300356993720820710227751802158499423378169071566767176233660823037612291562375720947000704050973342567757625252803037688616515709365379954274063"); - EXPECT_THROW(exp(getTop()), - UndefinedFunctionException); + EXPECT_THAT( + [] { exp(getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(exp(-getTop()).toString(), "0.0"); EXPECT_EQ(exp(1 / getTop()).toString(), @@ -495,50 +550,80 @@ TEST(RealFunctionsTests, logTest) { EXPECT_EQ(log(Real("0.2435"), Real("0.00000684")).toString(), "8.4188022648009447163225799145503253101352002864631415297742615181622921460652203893252135022820887001341319601850770875520110928757753272796499436866770185110234096367992828394100601687613288221555097697261899842957945949684413331136056597578143523418528905203613881861131482071992287714071407638448773005224414092163126495683427152060080881159486144871539822246244096502129174394529727345020839956353246490469480019902233480738616934001479599668640841126968042303450589052841035577354726797101205172"); - EXPECT_THROW(log(Real("0"), Real("0")), - UndefinedFunctionException); - EXPECT_THROW(log(Real("1"), Real("66")), - UndefinedFunctionException); - EXPECT_THROW(log(Real("-1"), Real("66")), - UndefinedFunctionException); - EXPECT_THROW(log(Real("10"), Real("-10")), - UndefinedFunctionException); - EXPECT_THROW(log(Real("-10"), Real("10")), - UndefinedFunctionException); + EXPECT_THAT( + [] { log(Real("0"), Real("0")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { log(Real("1"), Real("66")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { log(Real("-1"), Real("66")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { log(Real("10"), Real("-10")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { log(Real("-10"), Real("10")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(log(getBottom(), 2).toString(), "0.00060232170720148787335668247421703824233401793451907250732522916773385188954022906541837983996988431059094169862536414811557500495692329813203780906742857930168615297869764675322448206577626017712119000549151745205989997178535528834383829035005402069701450414530378257833776070969021526094444364816945235600935174058268565904524492686376745284448718663559682349198279109942125716899713858375086069625495195599080433207462875895090264590143184205942381892712807641877394970943778378340993960349468596485"); - EXPECT_THROW(log(-getBottom(), 2), - UndefinedFunctionException); + EXPECT_THAT( + [] { log(-getBottom(), 2); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(log(1 / getBottom(), 2).toString(), "-0.00060232170720148787335668247421703824233401793451907250732522916773385188954022906541837983996988431059094169862536414811557500495692329813203780906742857930168615297869764675322448206577626017712119000549151745205989997178535528834383829035005402069701450414530378257833776070969021526094444364816945235600935174058268565904524492686376745284448718663559682349198279109942125716899713858375086069625495195599080433207462875895090264590143184205942381892712807641877394970943778378340993960349468596485"); - EXPECT_THROW(log(-1 / getLogBottom(), 2), - UndefinedFunctionException); + EXPECT_THAT( + [] { log(-1 / getLogBottom(), 2); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(log(1 + 1 / getLogBottom(), 2).toString(), "14963154.342193243093712422680699151218039448432193587925035209260728038442025299193161011575994641480733267603410795076728690433584657628985768067584936488667559367158689971672050622879383900097405635209428211341951760557078825755420138867544380597591843358031587606341538450740374340818539759287918718630178509911678830554597975722879609294487135551363296720303098811247554495036254205298081533919450324265477298924474830320510074612511552543256262421158570339037070105389548400264147722652605567058"); EXPECT_EQ(log(1 - 1 / getLogBottom(), 2).toString(), "-14963153.649046062533766989312806358204380132571285775672422334025760220766251209439677029312401130838446029433818113410281395034922507978017975984060675629138377197348662974614554022611743937520407130897559671111307912059737145360364966233212630661876029704672607678956857740095364811145206406331320973952493609990097452764896860389596820154454690636445526725151914481416015887811174583083122205222815129307965002439358242471444513582333540499948851074193241291292412608104867497408832830908537979595"); - EXPECT_THROW(log(-1 + 1 / getLogBottom(), 2), - UndefinedFunctionException); - EXPECT_THROW(log(-1 - 1 / getLogBottom(), 2), - UndefinedFunctionException); + EXPECT_THAT( + [] { log(-1 + 1 / getLogBottom(), 2); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { log(-1 - 1 / getLogBottom(), 2); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(log(getTop(), 2).toString(), "0.00060179876403741195722267317028855276394958413863600696746297947633334990788320974726870323010323169588434938957603948500307384601018276229818373404501474310740195421987299739513709619111109837324557071587494251284044564219729803312816295558386812381034330050678075348580043519249230961108398858937009744461829681015882625617053962800932198087109777009790513513968156196421213763732007888196867038077809114726287574264983420066015703482789580169600344172129477299815596840195855948016245613690226508255"); - EXPECT_THROW(log(-getTop(), 2), - UndefinedFunctionException); + EXPECT_THAT( + [] { log(-getTop(), 2); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(log(1 / getTop(), 2).toString(), "-0.00060179876403741195722267317028855276394958413863600696746297947633334990788320974726870323010323169588434938957603948500307384601018276229818373404501474310740195421987299739513709619111109837324557071587494251284044564219729803312816295558386812381034330050678075348580043519249230961108398858937009744461829681015882625617053962800932198087109777009790513513968156196421213763732007888196867038077809114726287574264983420066015703482789580169600344172129477299815596840195855948016245613690226508255"); - EXPECT_THROW(log(-1 / getLogTop(), 2), - UndefinedFunctionException); - EXPECT_THROW(log(1 + 1 / getLogTop(), 2), - UndefinedFunctionException); - EXPECT_THROW(log(1 - 1 / getLogTop(), 2), - UndefinedFunctionException); - EXPECT_THROW(log(-1 + 1 / getLogTop(), 2), - UndefinedFunctionException); - EXPECT_THROW(log(-1 - 1 / getLogTop(), 2), - UndefinedFunctionException); + EXPECT_THAT( + [] { log(-1 / getLogTop(), 2); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { log(1 + 1 / getLogTop(), 2); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { log(1 - 1 / getLogTop(), 2); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { log(-1 + 1 / getLogTop(), 2); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { log(-1 - 1 / getLogTop(), 2); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); } TEST(RealFunctionsTests, lnTest) { @@ -549,44 +634,68 @@ TEST(RealFunctionsTests, lnTest) { EXPECT_EQ(ln(Real("66")).toString(), "4.1896547420264255448744209363458315725446975461204218810739420522614615391015403955545337898127855677446872359746665499983090936202844377734407750132034614375855322466924278989591414054061908800439205842378476964717818785535562556221481423253679976493420852339317987961870493593040854711141491246445359358373722644761959819863963576390829124879365541233265787258798046029241557202934580563944417723930344537189078848697331335312087479189786893021895715688916117667659732380841091142872749455090483267"); - EXPECT_THROW(ln(Real("0")), - UndefinedFunctionException); - EXPECT_THROW(ln(Real("-1")), - UndefinedFunctionException); + EXPECT_THAT( + [] { ln(Real("0")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { ln(Real("-1")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(ln(getBottom()).toString(), "1150.7922963302310752589242362151479313201731416891692833911699400851637036457415027739371939670841652308917357020983836730332705230349503481680214714976474839209077565316325602764151150216708300128886161589992601482604232651461734619835153032025914096909878125883457082637067939111344489500238615160009909178260268499686021249686533307312007952386375303998821252181168668959796267869490105263893896521620725067223980718367681264027500730584855433248242010154290038201336903273791780223593743126300917"); - EXPECT_THROW(ln(-getBottom()), - UndefinedFunctionException); + EXPECT_THAT( + [] { ln(-getBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(ln(1 / getBottom()).toString(), "-1150.7922963302310752589242362151479313201731416891692833911699400851637036457415027739371939670841652308917357020983836730332705230349503481680214714976474839209077565316325602764151150216708300128886161589992601482604232651461734619835153032025914096909878125883457082637067939111344489500238615160009909178260268499686021249686533307312007952386375303998821252181168668959796267869490105263893896521620725067223980718367681264027500730584855433248242010154290038201336903273791780223593743126300917"); - EXPECT_THROW(ln(-1 / getBottom()), - UndefinedFunctionException); + EXPECT_THAT( + [] { ln(-1 / getBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(ln(1 + 1 / getLogBottom()).toString(), "4.6323600272263608359211448156691072758876883168532246396075018549197775864381748298765365178030226248931374034769820083630251670816629519619538771280826564142288757639085979249471768209927217584931411470222413930228246265766896137048119643681987110433036930098119342190809014298077854480927710521960607704530573579776137719257059197071981057875303104096646125993974912722187860475512221757680333935876388355834671077676526614466116968774936860874832197537416426668522106100035121945103848322706376739*10^-8"); EXPECT_EQ(ln(1 - 1 / getLogBottom()).toString(), "-4.6323602418139649948376866797514572995752197210491058307576641336724719216383352361062914663674587656808848656687346701431219655465277394329551348639843630422542096702434001605272127288895929327215751563898813796074182163877372714057313772012933040704156169358608742070625510148804860304660664175014151072551726215293399858991624334681638597053383486705746061983545762472894857379243882709348125599832720555810145898279618567784920213785469969120637225339355267781491799812225999918525565812072662816*10^-8"); - EXPECT_THROW(ln(-1 + 1 / getLogBottom()), - UndefinedFunctionException); - EXPECT_THROW(ln(-1 - 1 / getLogBottom()), - UndefinedFunctionException); + EXPECT_THAT( + [] { ln(-1 + 1 / getLogBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { ln(-1 - 1 / getLogBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(ln(getTop()).toString(), "1151.7922966635646085924004268024496095309282755109697640151737838982364673175055998951467299258996052465500220510896818993462124890472738694984769323698716068886745193057012811943430642366646091837561108162687936796823299767705815255181578427768061307290354919840683949388317852313255500361482131430137488582877970196536516803839211139492790968508269095773231100312182466822895779683752382008537434837173083611909767545379191434734806361489542919224380933936036537329432840742844554171617404889632642"); - EXPECT_THROW(ln(-getTop()), - UndefinedFunctionException); + EXPECT_THAT( + [] { ln(-getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(ln(1 / getTop()).toString(), "-1151.7922966635646085924004268024496095309282755109697640151737838982364673175055998951467299258996052465500220510896818993462124890472738694984769323698716068886745193057012811943430642366646091837561108162687936796823299767705815255181578427768061307290354919840683949388317852313255500361482131430137488582877970196536516803839211139492790968508269095773231100312182466822895779683752382008537434837173083611909767545379191434734806361489542919224380933936036537329432840742844554171617404889632642"); - EXPECT_THROW(ln(-1 / getTop()), - UndefinedFunctionException); - EXPECT_THROW(ln(1 + 1 / getLogTop()), - UndefinedFunctionException); - EXPECT_THROW(ln(1 - 1 / getLogTop()), - UndefinedFunctionException); - EXPECT_THROW(ln(-1 + 1 / getLogTop()), - UndefinedFunctionException); - EXPECT_THROW(ln(-1 - 1 / getLogTop()), - UndefinedFunctionException); + EXPECT_THAT( + [] { ln(-1 / getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { ln(1 + 1 / getLogTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { ln(1 - 1 / getLogTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { ln(-1 + 1 / getLogTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { ln(-1 - 1 / getLogTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); } TEST(RealFunctionsTests, lbTest) { @@ -599,44 +708,68 @@ TEST(RealFunctionsTests, lbTest) { EXPECT_EQ(lb(Real("1024")).toString(), "10.0"); - EXPECT_THROW(lb(Real("0")), - UndefinedFunctionException); - EXPECT_THROW(lb(Real("-1")), - UndefinedFunctionException); + EXPECT_THAT( + [] { lb(Real("0")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { lb(Real("-1")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(lb(getBottom()).toString(), "1660.2423390088468152391910752389223371556027033502350030047043970665552604033557193348632239845183566271017417710501538215097901794377254202764363841871643747071564808438403849686328703846578940097114426960217287346753381210056644885659785581770910105170063280253795447247762538890216319599066790175392754544932873241866224231658503043157397318916028330680138739335892411716116576564640798839083902475693032164084479471776090955137972737315592315237578699070714960186770111882960267580469773996621113"); - EXPECT_THROW(lb(-getBottom()), - UndefinedFunctionException); + EXPECT_THAT( + [] { lb(-getBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(lb(1 / getBottom()).toString(), "-1660.2423390088468152391910752389223371556027033502350030047043970665552604033557193348632239845183566271017417710501538215097901794377254202764363841871643747071564808438403849686328703846578940097114426960217287346753381210056644885659785581770910105170063280253795447247762538890216319599066790175392754544932873241866224231658503043157397318916028330680138739335892411716116576564640798839083902475693032164084479471776090955137972737315592315237578699070714960186770111882960267580469773996621113"); - EXPECT_THROW(lb(-1 / getBottom()), - UndefinedFunctionException); + EXPECT_THAT( + [] { lb(-1 / getBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(lb(1 + 1 / getLogBottom()).toString(), "6.6830828388917342891547486506847285272697011778553511348949644332867998614145798830938470048136194213017431224868715797761885633680790132044146091615119170196741798630401321276786841802843498968365743316373147452925462901218524916301183034992001817086023359871860301036108309491023873401867078175761078204601368178509939844185624097243114009597752846308861275905256459124059713686286528167411921428262024218955687308981115116829854695701605260995123094905260651631487252496425326512975747703200977325*10^-8"); EXPECT_EQ(lb(1 - 1 / getLogBottom()).toString(), "-6.6830831484762066454675431422618825159987009233331409228534171430721783908516912969136729509928481419301908889301013133376453055787330828035242245174918370788506914927006846997402561569218574136561328101264573366071228147749489667517185452979226874060919022014009523263275164170543945098746986850351969607585674398333075312204333527471490256380337562966263984228239648580231885737336077106126682033590185973637834381756120060255959619721822463124707428302867531505814243457204894530719616210924893046*10^-8"); - EXPECT_THROW(lb(-1 + 1 / getLogBottom()), - UndefinedFunctionException); - EXPECT_THROW(lb(-1 - 1 / getLogBottom()), - UndefinedFunctionException); + EXPECT_THAT( + [] { lb(-1 + 1 / getLogBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { lb(-1 - 1 / getLogBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(lb(getTop()).toString(), "1661.6850345306344141487530796177690746215158836948925002095220520038185509989931038272246710097629299710429990443367317181033697520479130844014839956432996829364738082384471341579821245656450941161111418270425586144696676643091196292534437222731085099151401430686452988712060138169216117489101036905404477911088920929597538663365923888861719817611791774685691023049143284296171501716483628778816866896852353629726107200682703242297950283551340834724294269534579127490555479536375902006763171420106197"); - EXPECT_THROW(lb(-getTop()), - UndefinedFunctionException); + EXPECT_THAT( + [] { lb(-getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(lb(1 / getTop()).toString(), "-1661.6850345306344141487530796177690746215158836948925002095220520038185509989931038272246710097629299710429990443367317181033697520479130844014839956432996829364738082384471341579821245656450941161111418270425586144696676643091196292534437222731085099151401430686452988712060138169216117489101036905404477911088920929597538663365923888861719817611791774685691023049143284296171501716483628778816866896852353629726107200682703242297950283551340834724294269534579127490555479536375902006763171420106197"); - EXPECT_THROW(lb(-1 / getTop()), - UndefinedFunctionException); - EXPECT_THROW(lb(1 + 1 / getLogTop()), - UndefinedFunctionException); - EXPECT_THROW(lb(1 - 1 / getLogTop()), - UndefinedFunctionException); - EXPECT_THROW(lb(-1 + 1 / getLogTop()), - UndefinedFunctionException); - EXPECT_THROW(lb(-1 - 1 / getLogTop()), - UndefinedFunctionException); + EXPECT_THAT( + [] { lb(-1 / getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { lb(1 + 1 / getLogTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { lb(1 - 1 / getLogTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { lb(-1 + 1 / getLogTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { lb(-1 - 1 / getLogTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); } TEST(RealFunctionsTests, lgTest) { @@ -649,44 +782,68 @@ TEST(RealFunctionsTests, lgTest) { EXPECT_EQ(lg(Real("25")).toString(), "1.3979400086720376095725222105510139464636202370757829173791450777457836214511509810261454957636276559186310456171380092418104642377329529880006153325906088498709940714916131946763605313767941129976321942036428347656911209362761419072922306009595213783007750749191994733748107570423083053634346546320353476069144129847373649032981457220701061644284621638984199848009038243690805708299360702447477550154183417636180970020056567602790446469998643589641748853427426633159991941589803258308555502090114049"); - EXPECT_THROW(lg(Real("0")), - UndefinedFunctionException); - EXPECT_THROW(lg(Real("-1")), - UndefinedFunctionException); + EXPECT_THAT( + [] { lg(Real("0")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { lg(Real("-1")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(lg(getBottom()).toString(), "499.78274411299115434676719965223768779167964136920007055363841585463644188622791943555370510164980964264750094313258593253768816086436746615232975204548281091270192678941451207329501545599209700116287734424296607709230395802024565114215533908757411944516763884090982261616328224420567778290181253387292750617933539643330552558518205798043923795251523923586037612283521406459121448490318126006960906308176149951008770475545170983614291254760922234519816329245038107624609046278865956610110296462324552"); - EXPECT_THROW(lg(-getBottom()), - UndefinedFunctionException); + EXPECT_THAT( + [] { lg(-getBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(lg(1 / getBottom()).toString(), "-499.78274411299115434676719965223768779167964136920007055363841585463644188622791943555370510164980964264750094313258593253768816086436746615232975204548281091270192678941451207329501545599209700116287734424296607709230395802024565114215533908757411944516763884090982261616328224420567778290181253387292750617933539643330552558518205798043923795251523923586037612283521406459121448490318126006960906308176149951008770475545170983614291254760922234519816329245038107624609046278865956610110296462324552"); - EXPECT_THROW(lg(-1 / getBottom()), - UndefinedFunctionException); + EXPECT_THAT( + [] { lg(-1 / getBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(lg(1 + 1 / getLogBottom()).toString(), "2.0118083980136059096853434888142725109436709718011389861452655487998101335198937186475792783475983528667713471278999353571427318335463536665832676784887325437368177755415090648923706314921768803261907182208662223893200401867605259641745584319375168426834845475247780539274153193313255028313714813446321763442399999146370680777253992458317214084017722141404310604446853968438354712208344696034596216350581382476247785306793448540127788042183387871859234405690320319579913363050300456144355260913054575*10^-8"); EXPECT_EQ(lg(1 - 1 / getLogBottom()).toString(), "-2.0118084912078182807420902078090487438954699922096761156253211468848051193024573881935808149245464415884943909535208439584744424064895057343999409001554072702232573612470198517753848891829489035460711247341029104077303724685445729129086771709504291590342477175777030466488750254387650200689200176200847160261425426622753483111550954791817472467095433096890416721603648181690701011424585813302233944898337824051565095996050613509755257069316927468635539620462707852017840963058700239856708772770957763*10^-8"); - EXPECT_THROW(lg(-1 + 1 / getLogBottom()), - UndefinedFunctionException); - EXPECT_THROW(lg(-1 - 1 / getLogBottom()), - UndefinedFunctionException); + EXPECT_THAT( + [] { lg(-1 + 1 / getLogBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { lg(-1 - 1 / getLogBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(lg(getTop()).toString(), "500.21703873965932033446069388899443301000188758874338645068247369777978188276137722252688424605970600893853927714983535582557236730510225838524295217100484539293318342301289243646059775923458762067839867333175852316509178327044942829214965210822082429417197201185525689704910240757839537066890081621757756380437386048194814809511491445030505791198598921869543591521133770911428148229663487063107650428872664624111572569774068160311266584524855638648630118535214458717640520183965265359385275880778024"); - EXPECT_THROW(lg(-getTop()), - UndefinedFunctionException); + EXPECT_THAT( + [] { lg(-getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(lg(1 / getTop()).toString(), "-500.21703873965932033446069388899443301000188758874338645068247369777978188276137722252688424605970600893853927714983535582557236730510225838524295217100484539293318342301289243646059775923458762067839867333175852316509178327044942829214965210822082429417197201185525689704910240757839537066890081621757756380437386048194814809511491445030505791198598921869543591521133770911428148229663487063107650428872664624111572569774068160311266584524855638648630118535214458717640520183965265359385275880778024"); - EXPECT_THROW(lg(-1 / getTop()), - UndefinedFunctionException); - EXPECT_THROW(lg(1 + 1 / getLogTop()), - UndefinedFunctionException); - EXPECT_THROW(lg(1 - 1 / getLogTop()), - UndefinedFunctionException); - EXPECT_THROW(lg(-1 + 1 / getLogTop()), - UndefinedFunctionException); - EXPECT_THROW(lg(-1 - 1 / getLogTop()), - UndefinedFunctionException); + EXPECT_THAT( + [] { lg(-1 / getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { lg(1 + 1 / getLogTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { lg(1 - 1 / getLogTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { lg(-1 + 1 / getLogTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { lg(-1 - 1 / getLogTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); } TEST(RealFunctionsTests, sinTest) { @@ -701,14 +858,22 @@ TEST(RealFunctionsTests, sinTest) { EXPECT_EQ(sin(Real("360")).toString(), "0.95891572341430650775887594775378440067396475320176419597230510239310187233155216762469333666238341968877803078186966928960032096690227561941454486085366726260909801244212617791982769634387261903781883823531474415994524980397676039997066747095237475703837143800063095336626267981859128776133587943412648564335693073303454697354580361100438284186802625914881351877222107015824075695678302538013095447706197595852901261436701189763894410700471281462208671109751813776339466816838916499612073892989487919"); - EXPECT_THROW(sin(Real(2 * getPi())), - UndefinedFunctionException); - EXPECT_THROW(sin(Real(-2 * getPi())), - UndefinedFunctionException); - EXPECT_THROW(sin(Real(getPi())), - UndefinedFunctionException); - EXPECT_THROW(sin(Real(-getPi())), - UndefinedFunctionException); + EXPECT_THAT( + [] { sin(Real(2 * getPi())); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { sin(Real(-2 * getPi())); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { sin(Real(getPi())); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { sin(Real(-getPi())); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(sin(Real(getPi() / 2)).toString(), "1.0"); EXPECT_EQ(sin(Real(-getPi() / 2)).toString(), @@ -735,14 +900,22 @@ TEST(RealFunctionsTests, sinTest) { EXPECT_EQ(sin(-1 - 1 / getBottom()).toString(), "-0.84147098480789650665250232163029899962256306079837106567275170999191040439123966894863974354305269585434903790792067429325911892099189888119341032772921240948079195582676660699990776401197840878273256634748480287029865615701796245539489357292467012708648628105338203056137721820386844966776167426623901338275339795676425556547796398976482432869027569642912063005830365152303127825528985326485139819345213597095596206217211481444178105760107567413664805500891672660580414007806239307037187795626128881"); - EXPECT_THROW(sin(getTop()), - UndefinedFunctionException); - EXPECT_THROW(sin(-getTop()), - UndefinedFunctionException); - EXPECT_THROW(sin(1 / getTop()), - UndefinedFunctionException); - EXPECT_THROW(sin(-1 / getTop()), - UndefinedFunctionException); + EXPECT_THAT( + [] { sin(getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { sin(-getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { sin(1 / getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { sin(-1 / getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(sin(1 + 1 / getTop()).toString(), "0.84147098480789650665250232163029899962256306079837106567275170999191040439123966894863974354305269585434903790792067429325911892099189888119341032772921240948079195582676660699990776401197840878273256634748480287029865615701796245539489357292467012708648628105338203056137721820386844966776167426623901338275339795676425556547796398976482432869027569642912063005830365152303127825528985326485139819345213597095596206217211481444178105760107567413664805500891672660580414007806239307037187795626128881"); EXPECT_EQ(sin(1 - 1 / getTop()).toString(), @@ -773,10 +946,14 @@ TEST(RealFunctionsTests, cosTest) { "-1.0"); EXPECT_EQ(cos(Real(-getPi())).toString(), "-1.0"); - EXPECT_THROW(cos(Real(getPi() / 2)), - UndefinedFunctionException); - EXPECT_THROW(cos(Real(-getPi() / 2)), - UndefinedFunctionException); + EXPECT_THAT( + [] { cos(Real(getPi() / 2)); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { cos(Real(-getPi() / 2)); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(cos(Real(getPi() / 4)).toString(), "0.70710678118654752440084436210484903928483593768847403658833986899536623923105351942519376716382078636750692311545614851246241802792536860632206074854996791570661133296375279637789997525057639103028573505477998580298513726729843100736425870932044459930477616461524215435716072541988130181399762570399484362669827316590441482031030762917619752737287514387998086491778761016876592850567718730170424942358019344998534950240751527201389515822712391153424646845931079028923155579833435650650780928449361862"); EXPECT_EQ(cos(Real(-getPi() / 4)).toString(), @@ -799,10 +976,14 @@ TEST(RealFunctionsTests, cosTest) { EXPECT_EQ(cos(-1 - 1 / getBottom()).toString(), "0.54030230586813971740093660744297660373231042061792222767009725538110039477447176451795185608718308934357173116003008909786063376002166345640651226541731858471797116447447949423311792455139325433594351775670289259637573615432754964175449177511513122273010063135707823223677140151746899593667873067422762024507763744067587498161784272021645585111563296889057108124272933169868524714568949043423754330944230240935962395831824547281736640780712434336217481003220271297578822917644683598726994264913443917"); - EXPECT_THROW(cos(getTop()), - UndefinedFunctionException); - EXPECT_THROW(cos(-getTop()), - UndefinedFunctionException); + EXPECT_THAT( + [] { cos(getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { cos(-getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(cos(1 / getTop()).toString(), "1.0"); EXPECT_EQ(cos(-1 / getTop()).toString(), @@ -831,18 +1012,30 @@ TEST(RealFunctionsTests, tanTest) { EXPECT_EQ(tan(Real("1.5")).toString(), "14.101419947171719387646083651987756445659543577235861866123267586089696270414155268648702926309442287045867838594565919691699004491669865025264248980039061351918594865941647830085172090316199132420462962006307262522713747887816074895835112885636990533301440984006371447953191752413056040636010883158885875789200937415934573118249197536454626507188777255849020779992691101711887207194991636234000277717211545383470167900668346883508414041371529451749917009685422130690021955751283209276658434501266213"); - EXPECT_THROW(tan(Real(2 * getPi())), - UndefinedFunctionException); - EXPECT_THROW(tan(Real(-2 * getPi())), - UndefinedFunctionException); - EXPECT_THROW(tan(Real(getPi())), - UndefinedFunctionException); - EXPECT_THROW(tan(Real(-getPi())), - UndefinedFunctionException); - EXPECT_THROW(tan(Real(getPi() / 2)), - UndefinedFunctionException); - EXPECT_THROW(tan(Real(-getPi() / 2)), - UndefinedFunctionException); + EXPECT_THAT( + [] { tan(Real(2 * getPi())); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { tan(Real(-2 * getPi())); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { tan(Real(getPi())); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { tan(Real(-getPi())); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { tan(Real(getPi() / 2)); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { tan(Real(-getPi() / 2)); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(tan(Real(getPi() / 4)).toString(), "1.0"); EXPECT_EQ(tan(Real(-getPi() / 4)).toString(), @@ -865,14 +1058,22 @@ TEST(RealFunctionsTests, tanTest) { EXPECT_EQ(tan(-1 - 1 / getBottom()).toString(), "-1.557407724654902230506974807458360173087250772381520038383946605698861397151727289555099965202242983804633821411748166613323554618124558937606071684548904439293586043167147908036824613274706955597341640610775535247302506796850507041352385144917621481627570027886022450772014016185772130673941664322369016675671795096261088233022485213114835059162969258761611173265010045945634821564335385053259780863154982428906189221075884887892422138520905365610443447236286192544657877827351485077390888070037216"); - EXPECT_THROW(tan(getTop()), - UndefinedFunctionException); - EXPECT_THROW(tan(-getTop()), - UndefinedFunctionException); - EXPECT_THROW(tan(1 / getTop()), - UndefinedFunctionException); - EXPECT_THROW(tan(-1 / getTop()), - UndefinedFunctionException); + EXPECT_THAT( + [] { tan(getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { tan(-getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { tan(1 / getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { tan(-1 / getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(tan(1 + 1 / getTop()).toString(), "1.5574077246549022305069748074583601730872507723815200383839466056988613971517272895550999652022429838046338214117481666133235546181245589376060716845489044392935860431671479080368246132747069555973416406107755352473025067968505070413523851449176214816275700278860224507720140161857721306739416643223690166756717950962610882330224852131148350591629692587616111732650100459456348215643353850532597808631549824289061892210758848878924221385209053656104434472362861925446578778273514850773908880700372159"); EXPECT_EQ(tan(1 - 1 / getTop()).toString(), @@ -895,21 +1096,35 @@ TEST(RealFunctionsTests, cotTest) { EXPECT_EQ(cot(Real("0.001")).toString(), "999.99966666664444444232804211640209502431508213496869579304205077674381954644639520634408395164810974790187059748663056319413799052324462182627171056687766083031520368701013112433153015271276878401509116019338890857459742077956424095491422840422498363560795969002271508729354091645914312319141941002918853623649271992390238327218620139099559359347286220707598821816371457779702994485393706092219607511288539620817165843202653888983899420142454517047661478883062764207608764656613887179725266038933487"); - EXPECT_THROW(cot(Real("0")), - UndefinedFunctionException); - - EXPECT_THROW(cot(Real(2 * getPi())), - UndefinedFunctionException); - EXPECT_THROW(cot(Real(-2 * getPi())), - UndefinedFunctionException); - EXPECT_THROW(cot(Real(getPi())), - UndefinedFunctionException); - EXPECT_THROW(cot(Real(-getPi())), - UndefinedFunctionException); - EXPECT_THROW(cot(Real(getPi() / 2)), - UndefinedFunctionException); - EXPECT_THROW(cot(Real(-getPi() / 2)), - UndefinedFunctionException); + EXPECT_THAT( + [] { cot(Real("0")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + + EXPECT_THAT( + [] { cot(Real(2 * getPi())); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { cot(Real(-2 * getPi())); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { cot(Real(getPi())); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { cot(Real(-getPi())); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { cot(Real(getPi() / 2)); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { cot(Real(-getPi() / 2)); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(cot(Real(getPi() / 4)).toString(), "1.0"); EXPECT_EQ(cot(Real(-getPi() / 4)).toString(), @@ -932,14 +1147,22 @@ TEST(RealFunctionsTests, cotTest) { EXPECT_EQ(cot(-1 - 1 / getBottom()).toString(), "-0.64209261593433070300641998659426562023027811391817137910116228042627685683916467219848291976019680465814306596047141573918356963493705933122378784310056202796590177952583993144431226921022120997092394574813060354777658685526661570956826754318872654659780710610492629489626709295081160952483427016354137699541561458952860701107858227259376088670827067970590687137491185081969260425814554198558997437568690607879275252280812126851999661677146531833095334863246223721746553979982097961711441872912451217"); - EXPECT_THROW(cot(getTop()), - UndefinedFunctionException); - EXPECT_THROW(cot(-getTop()), - UndefinedFunctionException); - EXPECT_THROW(cot(1 / getTop()), - UndefinedFunctionException); - EXPECT_THROW(cot(-1 / getTop()), - UndefinedFunctionException); + EXPECT_THAT( + [] { cot(getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { cot(-getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { cot(1 / getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { cot(-1 / getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(cot(1 + 1 / getTop()).toString(), "0.64209261593433070300641998659426562023027811391817137910116228042627685683916467219848291976019680465814306596047141573918356963493705933122378784310056202796590177952583993144431226921022120997092394574813060354777658685526661570956826754318872654659780710610492629489626709295081160952483427016354137699541561458952860701107858227259376088670827067970590687137491185081969260425814554198558997437568690607879275252280812126851999661677146531833095334863246223721746553979982097961711441872912451218"); EXPECT_EQ(cot(1 - 1 / getTop()).toString(), @@ -972,10 +1195,14 @@ TEST(RealFunctionsTests, secTest) { "-1.0"); EXPECT_EQ(sec(Real(-getPi())).toString(), "-1.0"); - EXPECT_THROW(sec(Real(getPi() / 2)), - UndefinedFunctionException); - EXPECT_THROW(sec(Real(-getPi() / 2)), - UndefinedFunctionException); + EXPECT_THAT( + [] { sec(Real(getPi() / 2)); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { sec(Real(-getPi() / 2)); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(sec(Real(getPi() / 4)).toString(), "1.4142135623730950488016887242096980785696718753769480731766797379907324784621070388503875343276415727350138462309122970249248360558507372126441214970999358314132226659275055927557999505011527820605714701095599716059702745345968620147285174186408891986095523292304843087143214508397626036279952514079896872533965463318088296406206152583523950547457502877599617298355752203375318570113543746034084988471603868999706990048150305440277903164542478230684929369186215805784631115966687130130156185689872372"); EXPECT_EQ(sec(Real(-getPi() / 4)).toString(), @@ -998,10 +1225,14 @@ TEST(RealFunctionsTests, secTest) { EXPECT_EQ(sec(-1 - 1 / getBottom()).toString(), "1.8508157176809256179117532413986501934703966550940092988351582778588154112615967059218414132873066711491035115807339528416408998731176774131560787241383862147409231241515235786388237571054049733204438514990354855937330333279994572038442605499267955577813651494388974489708121098698689024822929458998871134135427663188500839953123828815800381513006621410411846961570477808388478499442707545318664792285082946656651090325360041775536641555012184458039002171415610374409790953100073117119984608557958767"); - EXPECT_THROW(sec(getTop()), - UndefinedFunctionException); - EXPECT_THROW(sec(-getTop()), - UndefinedFunctionException); + EXPECT_THAT( + [] { sec(getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { sec(-getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(sec(1 / getTop()).toString(), "1.0"); EXPECT_EQ(sec(-1 / getTop()).toString(), @@ -1030,17 +1261,27 @@ TEST(RealFunctionsTests, cscTest) { EXPECT_EQ(csc(Real("-1")).toString(), "-1.1883951057781212162615994523745510035278298340979626252652536663591843673571904879136635680308530232472479285607355300046767997261054621744411787730114762446028425233143142004017226704681329668496699454726395217600143376991057765233165669093621429979755229705180663841364565078822602575834843221309765112529134018803701291196253064696269055657610587513727537585232559260303432589997118789357728292536966170276437169716491704026280178391400624291988181131298891953546837005862558906922729413477101737"); - EXPECT_THROW(csc(Real("0")), - UndefinedFunctionException); - - EXPECT_THROW(csc(Real(2 * getPi())), - UndefinedFunctionException); - EXPECT_THROW(csc(Real(-2 * getPi())), - UndefinedFunctionException); - EXPECT_THROW(csc(Real(getPi())), - UndefinedFunctionException); - EXPECT_THROW(csc(Real(-getPi())), - UndefinedFunctionException); + EXPECT_THAT( + [] { csc(Real("0")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + + EXPECT_THAT( + [] { csc(Real(2 * getPi())); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { csc(Real(-2 * getPi())); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { csc(Real(getPi())); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { csc(Real(-getPi())); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(csc(Real(getPi() / 2)).toString(), "1.0"); EXPECT_EQ(csc(Real(-getPi() / 2)).toString(), @@ -1067,14 +1308,22 @@ TEST(RealFunctionsTests, cscTest) { EXPECT_EQ(csc(-1 - 1 / getBottom()).toString(), "-1.1883951057781212162615994523745510035278298340979626252652536663591843673571904879136635680308530232472479285607355300046767997261054621744411787730114762446028425233143142004017226704681329668496699454726395217600143376991057765233165669093621429979755229705180663841364565078822602575834843221309765112529134018803701291196253064696269055657610587513727537585232559260303432589997118789357728292536966170276437169716491704026280178391400624291988181131298891953546837005862558906922729413477101736"); - EXPECT_THROW(csc(getTop()), - UndefinedFunctionException); - EXPECT_THROW(csc(-getTop()), - UndefinedFunctionException); - EXPECT_THROW(csc(1 / getTop()), - UndefinedFunctionException); - EXPECT_THROW(csc(-1 / getTop()), - UndefinedFunctionException); + EXPECT_THAT( + [] { csc(getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { csc(-getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { csc(1 / getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { csc(-1 / getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(csc(1 + 1 / getTop()).toString(), "1.1883951057781212162615994523745510035278298340979626252652536663591843673571904879136635680308530232472479285607355300046767997261054621744411787730114762446028425233143142004017226704681329668496699454726395217600143376991057765233165669093621429979755229705180663841364565078822602575834843221309765112529134018803701291196253064696269055657610587513727537585232559260303432589997118789357728292536966170276437169716491704026280178391400624291988181131298891953546837005862558906922729413477101736"); EXPECT_EQ(csc(1 - 1 / getTop()).toString(), @@ -1099,44 +1348,68 @@ TEST(RealFunctionsTests, asinTest) { EXPECT_EQ(asin(Real("-0.84")).toString(), "-0.99728322237179986604941509532521395934714998516818417157450478882243040040739064902926893714026459287035064571130233073211754382793258492775437715855004671674889185623000769840763429304713098716629852727968827073908276636401276048204827877385901902774150173708596546031159844406856310972438478179578175951803710882156311730333179191202945257138910105504820794989813222587723991409775037600465013785958465561810434613925198365489052649647827967461192622015741352528579453326828887043801608108051477269"); - EXPECT_THROW(asin(Real("10")), - UndefinedFunctionException); - EXPECT_THROW(asin(Real("-10")), - UndefinedFunctionException); - - EXPECT_THROW(asin(getBottom()), - UndefinedFunctionException); - EXPECT_THROW(asin(-getBottom()), - UndefinedFunctionException); + EXPECT_THAT( + [] { asin(Real("10")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { asin(Real("-10")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + + EXPECT_THAT( + [] { asin(getBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { asin(-getBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(asin(1 / getBottom()).toString(), "1.649133777606550136784218687424004095254941179759911333322637797136168830422634602314115700570892532765885213315763059469571051644237637081484422101463976767747598782769417969433884505005703538555118938103621519633425441890710503685760392630169558339325007093682810777671600073987912657467898712686051207323137042203911162690969426661891984432432828752922861693151232817522147506107429166604238235729862621545138953775084345915962310286003786258852115334834242333756164161942927832989128545815901011*10^-500"); EXPECT_EQ(asin(-1 / getBottom()).toString(), "-1.649133777606550136784218687424004095254941179759911333322637797136168830422634602314115700570892532765885213315763059469571051644237637081484422101463976767747598782769417969433884505005703538555118938103621519633425441890710503685760392630169558339325007093682810777671600073987912657467898712686051207323137042203911162690969426661891984432432828752922861693151232817522147506107429166604238235729862621545138953775084345915962310286003786258852115334834242333756164161942927832989128545815901011*10^-500"); - EXPECT_THROW(asin(1 + 1 / getBottom()), - UndefinedFunctionException); + EXPECT_THAT( + [] { asin(1 + 1 / getBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(asin(1 - 1 / getBottom()).toString(), "1.5707963267948966192313216916397514420985846996875529104874722961539082031431044993140174126710585339910740432566411533235469223047752911158626797040642405587251420513509692605527798223114744774651909822144054878329667230642378241168933915826356009543912129524492324911746294869466144351334645739492814493392173080120000958159852068569162071237110901347121303126022389964745087204086224350396918759598758653434173964159689735465688654414318032072936064099095247650063335973521689401338531070936559496"); EXPECT_EQ(asin(-1 + 1 / getBottom()).toString(), "-1.5707963267948966192313216916397514420985846996875529104874722961539082031431044993140174126710585339910740432566411533235469223047752911158626797040642405587251420513509692605527798223114744774651909822144054878329667230642378241168933915826356009543912129524492324911746294869466144351334645739492814493392173080120000958159852068569162071237110901347121303126022389964745087204086224350396918759598758653434173964159689735465688654414318032072936064099095247650063335973521689401338531070936559496"); - EXPECT_THROW(asin(-1 - 1 / getBottom()), - UndefinedFunctionException); - - EXPECT_THROW(asin(getTop()), - UndefinedFunctionException); - EXPECT_THROW(asin(-getTop()), - UndefinedFunctionException); - EXPECT_THROW(asin(1 / getTop()), - UndefinedFunctionException); - EXPECT_THROW(asin(-1 / getTop()), - UndefinedFunctionException); - EXPECT_THROW(asin(1 + 1 / getTop()), - UndefinedFunctionException); + EXPECT_THAT( + [] { asin(-1 - 1 / getBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + + EXPECT_THAT( + [] { asin(getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { asin(-getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { asin(1 / getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { asin(-1 / getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { asin(1 + 1 / getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(asin(1 - 1 / getTop()).toString(), "1.5707963267948966192313216916397514420985846996875529104874722961539082031431044993140174126710585339910740432566411533235469223047752911158626797040642405587251420513509692605527798223114744774651909822144054878329667230642378241168933915826356009544626714614102467331749140037017778707281343108720908767252437637606686704112448519217753623331070673065952614115246421127884387262543844228820964934513815710803478219109453922658176229218505271474546070789591352895215538283417829914082233990617199866"); EXPECT_EQ(asin(-1 + 1 / getTop()).toString(), "-1.5707963267948966192313216916397514420985846996875529104874722961539082031431044993140174126710585339910740432566411533235469223047752911158626797040642405587251420513509692605527798223114744774651909822144054878329667230642378241168933915826356009544626714614102467331749140037017778707281343108720908767252437637606686704112448519217753623331070673065952614115246421127884387262543844228820964934513815710803478219109453922658176229218505271474546070789591352895215538283417829914082233990617199866"); - EXPECT_THROW(asin(-1 - 1 / getTop()), - UndefinedFunctionException); + EXPECT_THAT( + [] { asin(-1 - 1 / getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); } TEST(RealFunctionsTests, acosTest) { @@ -1151,44 +1424,64 @@ TEST(RealFunctionsTests, acosTest) { EXPECT_EQ(acos(Real("0.54")).toString(), "1.0003592173949747118791376298435469512885913377969497906049204887187423921567895177976022221907050335650845132822965716649845600735516029413986139650461173550128803998067400065310353542792427835105916184592623138459755250330281624455815464611629996440114260012860252020183567009333702645210375334263809552895280288326212717942179665352569519572762060481581698696284766538229040683728130641302999291849537143100925393941523072142724992850232516181797925495768215872066743637596358371283895797058420554"); - EXPECT_THROW(acos(Real("10")), - UndefinedFunctionException); - EXPECT_THROW(acos(Real("-10")), - UndefinedFunctionException); - - EXPECT_THROW(acos(getBottom()), - UndefinedFunctionException); - EXPECT_THROW(acos(-getBottom()), - UndefinedFunctionException); + EXPECT_THAT( + [] { acos(Real("10")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { acos(Real("-10")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + + EXPECT_THAT( + [] { acos(getBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { acos(-getBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(acos(1 / getBottom()).toString(), "1.5707963267948966192313216916397514420985846996875529104874722961539082031431044993140174126710585339910740432566411533235469223047752911158626797040642405587251420513509692605527798223114744774651909822144054878329667230642378241168933915826356009545728242834617301743052271633241066968036301245706368622935033031577940874407604604814146270458576821839462951800056652652744102332606920734759707558047165286351828797959765460930586909663058965525592740372311899813747836759428763624456139690915059745"); EXPECT_EQ(acos(-1 / getBottom()).toString(), "1.5707963267948966192313216916397514420985846996875529104874722961539082031431044993140174126710585339910740432566411533235469223047752911158626797040642405587251420513509692605527798223114744774651909822144054878329667230642378241168933915826356009545728242834617301743052271633241066968036301245706368622935033031577940874407604604814146270458576821839462951800056652652744102332606920734759707558047165286351828797959765460930586909663058965525592740372311899813747836759428763624456139690915059746"); - EXPECT_THROW(acos(1 + 1 / getBottom()), - UndefinedFunctionException); + EXPECT_THAT( + [] { acos(1 + 1 / getBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(acos(1 - 1 / getBottom()).toString(), "1.8161133101249768313059767637749226167016555062135541295428599514579399162477525362449841992214659204923416486740342626879990151285206963843627887984484066329176548338000757254648982552487409334526566762732166521636845007859070742231176086199785002494824233671741808993871471604475449814991979005026904466371335432200684754360612792364909810664574323876073450385968843689808751624105899580384533574694605556028984635741348186918197680661361994642285426418712562403143105149802614347742290494321962424*10^-250"); EXPECT_EQ(acos(-1 + 1 / getBottom()).toString(), "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019089640372359109626654798566502707211319370946985199183116327206111697941832567456673383308341695687723186584254926079042617489189536693145085156626317645923939786002762119455196396275564077376997598528804471407147463811172732950453025794670761851619242"); - EXPECT_THROW(acos(-1 - 1 / getBottom()), - UndefinedFunctionException); - - EXPECT_THROW(acos(getTop()), - UndefinedFunctionException); - EXPECT_THROW(acos(-getTop()), - UndefinedFunctionException); + EXPECT_THAT( + [] { acos(-1 - 1 / getBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + + EXPECT_THAT( + [] { acos(getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { acos(-getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(acos(1 / getTop()).toString(), "1.5707963267948966192313216916397514420985846996875529104874722961539082031431044993140174126710585339910740432566411533235469223047752911158626797040642405587251420513509692605527798223114744774651909822144054878329667230642378241168933915826356009545728242834617301743052271633241066968036301245706368622935033031577940874407604604814146270458576821839462951800056652652744102332606920734759707558047165286351828797959765460930586909663058965525592740372311899813747836759428763624456139690915059746"); EXPECT_EQ(acos(-1 / getTop()).toString(), "1.5707963267948966192313216916397514420985846996875529104874722961539082031431044993140174126710585339910740432566411533235469223047752911158626797040642405587251420513509692605527798223114744774651909822144054878329667230642378241168933915826356009545728242834617301743052271633241066968036301245706368622935033031577940874407604604814146270458576821839462951800056652652744102332606920734759707558047165286351828797959765460930586909663058965525592740372311899813747836759428763624456139690915059746"); - EXPECT_THROW(acos(1 + 1 / getTop()), - UndefinedFunctionException); + EXPECT_THAT( + [] { acos(1 + 1 / getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(acos(1 - 1 / getTop()).toString(), "1.1015282205148344113031315962232882607549581369854598556825953939712541702951560855963926471275061487735103376848102315248597150700630765059387426235333495755483505788503115382724106804445536940510466695827205469185322984760109337103739057002978598795971390260446685983828095271655143299592980169999703367652156688155730814358165398832394569722569002490431507814481217842691057439436763109599092031344149400752025936592695703741466909450253591955614422574626565454002410396637850800605126854091903233*10^-250"); EXPECT_EQ(acos(-1 + 1 / getTop()).toString(), "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019090354957448719769074801411670258845675317644354427277390187470669184627578520053124031899893789647494905415565915303073780628489595150764963580672492560980997155307017069219383588763138881564237000138811161903252708963375042846593538538373681532259612"); - EXPECT_THROW(acos(-1 - 1 / getTop()), - UndefinedFunctionException); + EXPECT_THAT( + [] { acos(-1 - 1 / getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); } TEST(RealFunctionsTests, atanTest) { @@ -1224,10 +1517,14 @@ TEST(RealFunctionsTests, atanTest) { "1.5707963267948966192313216916397514420985846996875529104874722961539082031431044993140174126710585339910740432566411533235469223047752911158626797040642405587251420513509692605527798223114744774651909822144054878329667230642378241168933915826356009545728242834617301743052271633241066968036301245706368622935033031577940874407604604814146270458576821839462951800056652652744102332606920734759707558047165286351828797959765460930586909663058965525592740372311899813747836759428763624456139690915059746"); EXPECT_EQ(atan(-getTop()).toString(), "-1.5707963267948966192313216916397514420985846996875529104874722961539082031431044993140174126710585339910740432566411533235469223047752911158626797040642405587251420513509692605527798223114744774651909822144054878329667230642378241168933915826356009545728242834617301743052271633241066968036301245706368622935033031577940874407604604814146270458576821839462951800056652652744102332606920734759707558047165286351828797959765460930586909663058965525592740372311899813747836759428763624456139690915059746"); - EXPECT_THROW(atan(1 / getTop()), - UndefinedFunctionException); - EXPECT_THROW(atan(-1 / getTop()), - UndefinedFunctionException); + EXPECT_THAT( + [] { atan(1 / getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { atan(-1 / getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(atan(1 + 1 / getTop()).toString(), "0.78539816339744830961566084581987572104929234984377645524373614807695410157155224965700870633552926699553702162832057666177346115238764555793133985203212027936257102567548463027638991115573723873259549110720274391648336153211891205844669579131780047728641214173086508715261358166205334840181506228531843114675165157889704372038023024070731352292884109197314759000283263263720511663034603673798537790235826431759143989798827304652934548315294827627963701861559499068739183797143818122280698454575298729"); EXPECT_EQ(atan(1 - 1 / getTop()).toString(), @@ -1248,8 +1545,10 @@ TEST(RealFunctionsTests, acotTest) { EXPECT_EQ(acot(Real("999.9996666666444444423280421164020950243150821349686957930420507767438195464464")).toString(), "0.00099999999999999999999999999999999999999999999999999999999999999999999999999999999520634568183674040783970331582554073275320346626391287599441844855329139555995768197166058821093605951741769596479352976180441333074229850093543964493443860640600490586849713950251489092715413226533897754456153271726325985194450173733913611757889318251097033681593161211552378778014959359303764665491769639631227095346657170959640829846817771528191249797072531699834783539726035526166348364413613552480681028846378824925"); - EXPECT_THROW(acot(Real("0")), - UndefinedFunctionException); + EXPECT_THAT( + [] { acot(Real("0")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(acot(getBottom()).toString(), "1.649133777606550136784218687424004095254941179759911333322637797136168830422634602314115700570892532765885213315763059469571051644237637081484422101463976767747598782769417969433884505005703538555118938103621519633425441890710503685760392630169558339325007093682810777671600073987912657467898712686051207323137042203911162690969426661891984432432828752922861693151232817522147506107429166604238235729862621545138953775084345915962310286003786258852115334834242333756164161942927832989128545815901011*10^-500"); @@ -1268,10 +1567,14 @@ TEST(RealFunctionsTests, acotTest) { EXPECT_EQ(acot(-1 - 1 / getBottom()).toString(), "-0.78539816339744830961566084581987572104929234984377645524373614807695410157155224965700870633552926699553702162832057666177346115238764555793133985203212027936257102567548463027638991115573723873259549110720274391648336153211891205844669579131780047728641214173086508715261358166205334840181506228531843114675165157889704372038023024070731352292884109197314759000283263263720511663034603673798537790235826431759143989798827304652934548315294827627963701861559499068739183797143818122280698454575298727"); - EXPECT_THROW(acot(getTop()), - UndefinedFunctionException); - EXPECT_THROW(acot(-getTop()), - UndefinedFunctionException); + EXPECT_THAT( + [] { acot(getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { acot(-getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(acot(1 / getTop()).toString(), "1.5707963267948966192313216916397514420985846996875529104874722961539082031431044993140174126710585339910740432566411533235469223047752911158626797040642405587251420513509692605527798223114744774651909822144054878329667230642378241168933915826356009545728242834617301743052271633241066968036301245706368622935033031577940874407604604814146270458576821839462951800056652652744102332606920734759707558047165286351828797959765460930586909663058965525592740372311899813747836759428763624456139690915059746"); EXPECT_EQ(acot(-1 / getTop()).toString(), @@ -1298,27 +1601,41 @@ TEST(RealFunctionsTests, asecTest) { EXPECT_EQ(asec(Real("-10")).toString(), "1.670963747956456415576844871092444760667260671917182451878496151190310876793967050967955277030562988946734134176737739291829990877833759136140587878535056524058956706576764088322420219334399421939192714470055959265395299736976094988871700052211659618789403459380175132202886777407283297893841109249077369000993428242193341002075242778034695067183281503984647497682025462516942323899967180141448103403423650549303602217381181878196941943974698615972920812149134256269952350202231220792042427298220536"); - EXPECT_THROW(asec(Real("0")), - UndefinedFunctionException); - EXPECT_THROW(asec(Real("0.54")), - UndefinedFunctionException); - EXPECT_THROW(asec(Real("-0.54")), - UndefinedFunctionException); + EXPECT_THAT( + [] { asec(Real("0")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { asec(Real("0.54")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { asec(Real("-0.54")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(asec(getBottom()).toString(), "1.5707963267948966192313216916397514420985846996875529104874722961539082031431044993140174126710585339910740432566411533235469223047752911158626797040642405587251420513509692605527798223114744774651909822144054878329667230642378241168933915826356009545728242834617301743052271633241066968036301245706368622935033031577940874407604604814146270458576821839462951800056652652744102332606920734759707558047165286351828797959765460930586909663058965525592740372311899813747836759428763624456139690915059745"); EXPECT_EQ(asec(-getBottom()).toString(), "1.5707963267948966192313216916397514420985846996875529104874722961539082031431044993140174126710585339910740432566411533235469223047752911158626797040642405587251420513509692605527798223114744774651909822144054878329667230642378241168933915826356009545728242834617301743052271633241066968036301245706368622935033031577940874407604604814146270458576821839462951800056652652744102332606920734759707558047165286351828797959765460930586909663058965525592740372311899813747836759428763624456139690915059746"); - EXPECT_THROW(asec(1 / getBottom()), - UndefinedFunctionException); - EXPECT_THROW(asec(-1 / getBottom()), - UndefinedFunctionException); + EXPECT_THAT( + [] { asec(1 / getBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { asec(-1 / getBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(asec(1 + 1 / getBottom()).toString(), "1.8161133101249768313059767637749226167016555062135541295428599514579399162477525362449841992214659204923416486740342626879990151285206963843627887984484066329176548338000757254648982552487409334526566762732166521636845007859070742231176086199785002494824233671741808993871471604475449814991979005026904466371335432200684754360612792364909810664574323876073450385968843689808751624105899580384533574694605556028984635741348186918197680661361994642285426418712562403143105149802614347742290494321962424*10^-250"); - EXPECT_THROW(asec(1 - 1 / getBottom()), - UndefinedFunctionException); - EXPECT_THROW(asec(-1 + 1 / getBottom()), - UndefinedFunctionException); + EXPECT_THAT( + [] { asec(1 - 1 / getBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { asec(-1 + 1 / getBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(asec(-1 - 1 / getBottom()).toString(), "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019089640372359109626654798566502707211319370946985199183116327206111697941832567456673383308341695687723186584254926079042617489189536693145085156626317645923939786002762119455196396275564077376997598528804471407147463811172732950453025794670761851619242"); @@ -1326,16 +1643,24 @@ TEST(RealFunctionsTests, asecTest) { "1.5707963267948966192313216916397514420985846996875529104874722961539082031431044993140174126710585339910740432566411533235469223047752911158626797040642405587251420513509692605527798223114744774651909822144054878329667230642378241168933915826356009545728242834617301743052271633241066968036301245706368622935033031577940874407604604814146270458576821839462951800056652652744102332606920734759707558047165286351828797959765460930586909663058965525592740372311899813747836759428763624456139690915059746"); EXPECT_EQ(asec(-getTop()).toString(), "1.5707963267948966192313216916397514420985846996875529104874722961539082031431044993140174126710585339910740432566411533235469223047752911158626797040642405587251420513509692605527798223114744774651909822144054878329667230642378241168933915826356009545728242834617301743052271633241066968036301245706368622935033031577940874407604604814146270458576821839462951800056652652744102332606920734759707558047165286351828797959765460930586909663058965525592740372311899813747836759428763624456139690915059746"); - EXPECT_THROW(asec(1 / getTop()), - UndefinedFunctionException); - EXPECT_THROW(asec(-1 / getTop()), - UndefinedFunctionException); + EXPECT_THAT( + [] { asec(1 / getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { asec(-1 / getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(asec(1 + 1 / getTop()).toString(), "1.1015282205148344113031315962232882607549581369854598556825953939712541702951560855963926471275061487735103376848102315248597150700630765059387426235333495755483505788503115382724106804445536940510466695827205469185322984760109337103739057002978598795971390260446685983828095271655143299592980169999703367652156688155730814358165398832394569722569002490431507814481217842691057439436763109599092031344149400752025936592695703741466909450253591955614422574626565454002410396637850800605126854091903233*10^-250"); - EXPECT_THROW(asec(1 - 1 / getTop()), - UndefinedFunctionException); - EXPECT_THROW(asec(-1 + 1 / getTop()), - UndefinedFunctionException); + EXPECT_THAT( + [] { asec(1 - 1 / getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { asec(-1 + 1 / getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(asec(-1 - 1 / getTop()).toString(), "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019090354957448719769074801411670258845675317644354427277390187470669184627578520053124031899893789647494905415565915303073780628489595150764963580672492560980997155307017069219383588763138881564237000138811161903252708963375042846593538538373681532259612"); } @@ -1354,44 +1679,70 @@ TEST(RealFunctionsTests, acscTest) { EXPECT_EQ(acsc(Real("-10")).toString(), "-0.10016742116155979634552317945269331856867597222962954139102385503640267365086255165393786435950445495566009092009658596828306857305846802027790817447081596533381465522579482776964039702292494447400173225565047143242857667273827087197830846957605866421657917591844495789765961408317660109021098467844050670749012508439925356131478229662006802132559932003835231767636019724253209063927510666547734759870712191412072242140463578513825097766880206341364677491794427489516867425935485834642845820671456144"); - EXPECT_THROW(acsc(Real("0")), - UndefinedFunctionException); - EXPECT_THROW(acsc(Real("0.54")), - UndefinedFunctionException); - EXPECT_THROW(acsc(Real("-0.54")), - UndefinedFunctionException); + EXPECT_THAT( + [] { acsc(Real("0")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { acsc(Real("0.54")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { acsc(Real("-0.54")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(acsc(getBottom()).toString(), "1.649133777606550136784218687424004095254941179759911333322637797136168830422634602314115700570892532765885213315763059469571051644237637081484422101463976767747598782769417969433884505005703538555118938103621519633425441890710503685760392630169558339325007093682810777671600073987912657467898712686051207323137042203911162690969426661891984432432828752922861693151232817522147506107429166604238235729862621545138953775084345915962310286003786258852115334834242333756164161942927832989128545815901011*10^-500"); EXPECT_EQ(acsc(-getBottom()).toString(), "-1.649133777606550136784218687424004095254941179759911333322637797136168830422634602314115700570892532765885213315763059469571051644237637081484422101463976767747598782769417969433884505005703538555118938103621519633425441890710503685760392630169558339325007093682810777671600073987912657467898712686051207323137042203911162690969426661891984432432828752922861693151232817522147506107429166604238235729862621545138953775084345915962310286003786258852115334834242333756164161942927832989128545815901011*10^-500"); - EXPECT_THROW(acsc(1 / getBottom()), - UndefinedFunctionException); - EXPECT_THROW(acsc(-1 / getBottom()), - UndefinedFunctionException); + EXPECT_THAT( + [] { acsc(1 / getBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { acsc(-1 / getBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(acsc(1 + 1 / getBottom()).toString(), "1.5707963267948966192313216916397514420985846996875529104874722961539082031431044993140174126710585339910740432566411533235469223047752911158626797040642405587251420513509692605527798223114744774651909822144054878329667230642378241168933915826356009543912129524492324911746294869466144351334645739492814493392173080120000958159852068569162071237110901347121303126022389964745087204086224350396918759598758653434173964159689735465688654414318032072936064099095247650063335973521689401338531070936559496"); - EXPECT_THROW(acsc(1 - 1 / getBottom()), - UndefinedFunctionException); - EXPECT_THROW(acsc(-1 + 1 / getBottom()), - UndefinedFunctionException); + EXPECT_THAT( + [] { acsc(1 - 1 / getBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { acsc(-1 + 1 / getBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(acsc(-1 - 1 / getBottom()).toString(), "-1.5707963267948966192313216916397514420985846996875529104874722961539082031431044993140174126710585339910740432566411533235469223047752911158626797040642405587251420513509692605527798223114744774651909822144054878329667230642378241168933915826356009543912129524492324911746294869466144351334645739492814493392173080120000958159852068569162071237110901347121303126022389964745087204086224350396918759598758653434173964159689735465688654414318032072936064099095247650063335973521689401338531070936559496"); - EXPECT_THROW(acsc(getTop()), - UndefinedFunctionException); - EXPECT_THROW(acsc(-getTop()), - UndefinedFunctionException); - EXPECT_THROW(acsc(1 / getTop()), - UndefinedFunctionException); - EXPECT_THROW(acsc(-1 / getTop()), - UndefinedFunctionException); + EXPECT_THAT( + [] { acsc(getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { acsc(-getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { acsc(1 / getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { acsc(-1 / getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(acsc(1 + 1 / getTop()).toString(), "1.5707963267948966192313216916397514420985846996875529104874722961539082031431044993140174126710585339910740432566411533235469223047752911158626797040642405587251420513509692605527798223114744774651909822144054878329667230642378241168933915826356009544626714614102467331749140037017778707281343108720908767252437637606686704112448519217753623331070673065952614115246421127884387262543844228820964934513815710803478219109453922658176229218505271474546070789591352895215538283417829914082233990617199866"); - EXPECT_THROW(acsc(1 - 1 / getTop()), - UndefinedFunctionException); - EXPECT_THROW(acsc(-1 + 1 / getTop()), - UndefinedFunctionException); + EXPECT_THAT( + [] { acsc(1 - 1 / getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { acsc(-1 + 1 / getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(acsc(-1 - 1 / getTop()).toString(), "-1.5707963267948966192313216916397514420985846996875529104874722961539082031431044993140174126710585339910740432566411533235469223047752911158626797040642405587251420513509692605527798223114744774651909822144054878329667230642378241168933915826356009544626714614102467331749140037017778707281343108720908767252437637606686704112448519217753623331070673065952614115246421127884387262543844228820964934513815710803478219109453922658176229218505271474546070789591352895215538283417829914082233990617199866"); } @@ -1412,10 +1763,14 @@ TEST(RealFunctionsTests, sinhTest) { EXPECT_EQ(sinh(Real("-1000000")).toString(), "-1.5166076984010437725432010707090571635419868974067387048030974998931132315932118262378896014238733712231453572791977727160648924261330240557869860774850358098312131563768360829761690407034195827198088986937033466934046726913218958947601036565089018349581925436647068674894225777805207965238477572592464354499304442433954381395399968367300979907629021482576602691540020197706252822827022193134154228496566284261501675246544829778210486724753160797320622498901320808395701922250790368495099757883193218*10^434294"); - EXPECT_THROW(sinh(getBottom()), - UndefinedFunctionException); - EXPECT_THROW(sinh(-getBottom()), - UndefinedFunctionException); + EXPECT_THAT( + [] { sinh(getBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { sinh(-getBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(sinh(1 / getBottom()).toString(), "1.649133777606550136784218687424004095254941179759911333322637797136168830422634602314115700570892532765885213315763059469571051644237637081484422101463976767747598782769417969433884505005703538555118938103621519633425441890710503685760392630169558339325007093682810777671600073987912657467898712686051207323137042203911162690969426661891984432432828752922861693151232817522147506107429166604238235729862621545138953775084345915962310286003786258852115334834242333756164161942927832989128545815901011*10^-500"); EXPECT_EQ(sinh(-1 / getBottom()).toString(), @@ -1429,14 +1784,22 @@ TEST(RealFunctionsTests, sinhTest) { EXPECT_EQ(sinh(-1 - 1 / getBottom()).toString(), "-1.1752011936438014568823818505956008151557179813340958702295654130133075673043238956071174520896233918404195333275795323567852189019194572821368403528832484238229689806253026878572974193778037894530156457975748559863812033933000211943571349392767479287838086397780915943822887094379183712322502306432683489821868659007368597138765536487737915436208491950598400985696957504601707347646045559914877642254885845736315892502135438245978143162874775249565935186798861968577094170390099113872716177152780263"); - EXPECT_THROW(sinh(getTop()), - UndefinedFunctionException); - EXPECT_THROW(sinh(-getTop()), - UndefinedFunctionException); - EXPECT_THROW(sinh(1 / getTop()), - UndefinedFunctionException); - EXPECT_THROW(sinh(-1 / getTop()), - UndefinedFunctionException); + EXPECT_THAT( + [] { sinh(getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { sinh(-getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { sinh(1 / getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { sinh(-1 / getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(sinh(1 + 1 / getTop()).toString(), "1.1752011936438014568823818505956008151557179813340958702295654130133075673043238956071174520896233918404195333275795323567852189019194572821368403528832484238229689806253026878572974193778037894530156457975748559863812033933000211943571349392767479287838086397780915943822887094379183712322502306432683489821868659007368597138765536487737915436208491950598400985696957504601707347646045559914877642254885845736315892502135438245978143162874775249565935186798861968577094170390099113872716177152780263"); EXPECT_EQ(sinh(1 - 1 / getTop()).toString(), @@ -1463,10 +1826,14 @@ TEST(RealFunctionsTests, coshTest) { EXPECT_EQ(cosh(Real("-1000000")).toString(), "1.5166076984010437725432010707090571635419868974067387048030974998931132315932118262378896014238733712231453572791977727160648924261330240557869860774850358098312131563768360829761690407034195827198088986937033466934046726913218958947601036565089018349581925436647068674894225777805207965238477572592464354499304442433954381395399968367300979907629021482576602691540020197706252822827022193134154228496566284261501675246544829778210486724753160797320622498901320808395701922250790368495099757883193218*10^434294"); - EXPECT_THROW(cosh(getBottom()), - UndefinedFunctionException); - EXPECT_THROW(cosh(-getBottom()), - UndefinedFunctionException); + EXPECT_THAT( + [] { cosh(getBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { cosh(-getBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(cosh(1 / getBottom()).toString(), "1.0"); EXPECT_EQ(cosh(-1 / getBottom()).toString(), @@ -1480,10 +1847,14 @@ TEST(RealFunctionsTests, coshTest) { EXPECT_EQ(cosh(-1 - 1 / getBottom()).toString(), "1.5430806348152437784779056207570616826015291123658637047374022147107690630492236989642647264355430355870468586044235275650321946947095862907634939423773472069151633480026408029059364105029494057980033657762593319443209506958499136898103743054847127392984561603903858174714536360045187363068275143488012027205749727055244716707064471032711422829394484116772731021396329586672730122826261409857215459162042522453939258584439199475134380734969475319971032521055637731102374474158960765443652715148207669"); - EXPECT_THROW(cosh(getTop()), - UndefinedFunctionException); - EXPECT_THROW(cosh(-getTop()), - UndefinedFunctionException); + EXPECT_THAT( + [] { cosh(getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { cosh(-getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(cosh(1 / getTop()).toString(), "1.0"); EXPECT_EQ(cosh(-1 / getTop()).toString(), @@ -1537,10 +1908,14 @@ TEST(RealFunctionsTests, tanhTest) { "1.0"); EXPECT_EQ(tanh(-getTop()).toString(), "-1.0"); - EXPECT_THROW(tanh(1 / getTop()).toString(), - UndefinedFunctionException); - EXPECT_THROW(tanh(-1 / getTop()).toString(), - UndefinedFunctionException); + EXPECT_THAT( + [] { tanh(1 / getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { tanh(-1 / getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(tanh(1 + 1 / getTop()).toString(), "0.76159415595576488811945828260479359041276859725793655159681050012195324457663848345894752167367671442190275970155407753236830911476248541329700666961132112539651013760808777643934099260420667955311747580113059006625778319752451237997591796119707757354591410814335043351567518059703276048802963895774140411055528274345747412887011673202243366614182042652138531498400801780942494059716650201970771112780762115100557417027786836013212010823078830175221024750850545493659202265152413525903793814306804484"); EXPECT_EQ(tanh(1 - 1 / getTop()).toString(), @@ -1567,8 +1942,10 @@ TEST(RealFunctionsTests, cothTest) { EXPECT_EQ(coth(Real("-1000000")).toString(), "-1.0"); - EXPECT_THROW(coth(Real("0")), - UndefinedFunctionException); + EXPECT_THAT( + [] { coth(Real("0")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(coth(getBottom()).toString(), "1.0"); @@ -1591,10 +1968,14 @@ TEST(RealFunctionsTests, cothTest) { "1.0"); EXPECT_EQ(coth(-getTop()).toString(), "-1.0"); - EXPECT_THROW(coth(1 / getTop()), - UndefinedFunctionException); - EXPECT_THROW(coth(-1 / getTop()), - UndefinedFunctionException); + EXPECT_THAT( + [] { coth(1 / getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { coth(-1 / getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(coth(1 + 1 / getTop()).toString(), "1.3130352854993313036361612469308478329120139412404526555431529675670842704618743826746792414808563029467947050738448204197703961861267108989696017535496187432786603952677415430193164214901222207116902698721736279449551078863534426431459421512705491545530284902291249287850149672463612993918572556026640725698026338831716611079696232602874932353108307435238960892539297808523447222896268792900584895961848078828348145997881467167886864925710322604873807663078752942123708924231550111748471298599194883"); EXPECT_EQ(coth(1 - 1 / getTop()).toString(), @@ -1621,10 +2002,14 @@ TEST(RealFunctionsTests, sechTest) { EXPECT_EQ(sech(Real("-1000000")).toString(), "6.5936629561771171579378159382154484171228030133167403192941769797906985007591094541101544505266576590003136623166279624437072289948914410518596660796372850144818311771718689218961756235736614332305572015788134843142823987619684063908579723392812450600316769828831818379538015455924132128248931752957164658625567427893359723762484980284103878781196254875345414062804199987764098081657081303453035863381229295149281777943984386777373544544747833870835791847918279021119342276015780078343555344003180895*10^-434295"); - EXPECT_THROW(sech(getBottom()).toString(), - UndefinedFunctionException); - EXPECT_THROW(sech(-getBottom()).toString(), - UndefinedFunctionException); + EXPECT_THAT( + [] { sech(getBottom()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { sech(-getBottom()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(sech(1 / getBottom()).toString(), "1.0"); EXPECT_EQ(sech(-1 / getBottom()).toString(), @@ -1638,10 +2023,14 @@ TEST(RealFunctionsTests, sechTest) { EXPECT_EQ(sech(-1 - 1 / getBottom()).toString(), "0.64805427366388539957497735322615032310848931207194202303786533731871759564671283028085478530789289238484741080920067693803371342199608047328527095053204320637710138926219751549816225165048045954767037456642342841785116074316762362109780982148957951547955724736187053107831495505487985321572485483727544183904287647250786507031934414748522969445640178730087299069355083406660792094751146726395612000124233338654264471442651311028781015766133420886738838930728215565261724863512460842165916753490629435"); - EXPECT_THROW(sech(getTop()).toString(), - UndefinedFunctionException); - EXPECT_THROW(sech(-getTop()).toString(), - UndefinedFunctionException); + EXPECT_THAT( + [] { sech(getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { sech(-getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(sech(1 / getTop()).toString(), "1.0"); EXPECT_EQ(sech(-1 / getTop()).toString(), @@ -1670,13 +2059,19 @@ TEST(RealFunctionsTests, cschTest) { EXPECT_EQ(csch(Real("-1000000")).toString(), "-6.5936629561771171579378159382154484171228030133167403192941769797906985007591094541101544505266576590003136623166279624437072289948914410518596660796372850144818311771718689218961756235736614332305572015788134843142823987619684063908579723392812450600316769828831818379538015455924132128248931752957164658625567427893359723762484980284103878781196254875345414062804199987764098081657081303453035863381229295149281777943984386777373544544747833870835791847918279021119342276015780078343555344003180895*10^-434295"); - EXPECT_THROW(csch(Real("0")), - UndefinedFunctionException); - - EXPECT_THROW(csch(getBottom()).toString(), - UndefinedFunctionException); - EXPECT_THROW(csch(-getBottom()).toString(), - UndefinedFunctionException); + EXPECT_THAT( + [] { csch(Real("0")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + + EXPECT_THAT( + [] { csch(getBottom()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { csch(-getBottom()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(csch(1 / getBottom()).toString(), "60637894486118500503636099732462364956850790907849127113254769591568608656948985194787389448417544101315522875333719830559375058059221999457285045467709773208236451195138842541700657594134640809985287947796233555965864294685760448475889927065472080334188866294714585098656713287282618832026757995083776993799896864197894811997715757204066567900975498475027932179243797839056728035498370647887472466931408463051355352585045395714991459137805650231442038783923968764653054533405715475155191362599633533.0"); EXPECT_EQ(csch(-1 / getBottom()).toString(), @@ -1690,14 +2085,22 @@ TEST(RealFunctionsTests, cschTest) { EXPECT_EQ(csch(-1 - 1 / getBottom()).toString(), "-0.85091812823932154513384276328717528418172466091033961699042115172900336432146510389973017732889381236244577208756327128688813072425711300301245714193374017994952769110096460382194385355935195067438882126357436553537332427446054349644213938204921347277018075690693498752022695416702001165378305540256814299412503544882032859324691046068505985960347029085439306176440022553590441722160679621286381402767940097301844636744314043849892045810662300858561471713244460798164774405712623774000961019889161073"); - EXPECT_THROW(csch(getTop()).toString(), - UndefinedFunctionException); - EXPECT_THROW(csch(-getTop()).toString(), - UndefinedFunctionException); - EXPECT_THROW(csch(1 / getTop()).toString(), - UndefinedFunctionException); - EXPECT_THROW(csch(-1 / getTop()).toString(), - UndefinedFunctionException); + EXPECT_THAT( + [] { csch(getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { csch(-getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { csch(1 / getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { csch(-1 / getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(csch(1 + 1 / getTop()).toString(), "0.85091812823932154513384276328717528418172466091033961699042115172900336432146510389973017732889381236244577208756327128688813072425711300301245714193374017994952769110096460382194385355935195067438882126357436553537332427446054349644213938204921347277018075690693498752022695416702001165378305540256814299412503544882032859324691046068505985960347029085439306176440022553590441722160679621286381402767940097301844636744314043849892045810662300858561471713244460798164774405712623774000961019889161074"); EXPECT_EQ(csch(1 - 1 / getTop()).toString(), @@ -1743,10 +2146,14 @@ TEST(RealFunctionsTests, asinhTest) { "1152.4854438441245539018176589239077860990037756453300192692944639077298609394752946107525932528960239340920235321102525850798980092830320000555096031215066828506052468765296526295333712752885008572272341663841581776375690972457542070930899079323308648685613749345214020341581518739796542753060280950574892886732978215978223220554397586621190650226114565343493816622827928325467853708568759742433820344125690295321140284116420724299741831747169440212977865955687122877079873810781098497093732339145146"); EXPECT_EQ(asinh(-getTop()).toString(), "-1152.4854438441245539018176589239077860990037756453300192692944639077298609394752946107525932528960239340920235321102525850798980092830320000555096031215066828506052468765296526295333712752885008572272341663841581776375690972457542070930899079323308648685613749345214020341581518739796542753060280950574892886732978215978223220554397586621190650226114565343493816622827928325467853708568759742433820344125690295321140284116420724299741831747169440212977865955687122877079873810781098497093732339145146"); - EXPECT_THROW(asinh(1 / getTop()).toString(), - UndefinedFunctionException); - EXPECT_THROW(asinh(-1 / getTop()).toString(), - UndefinedFunctionException); + EXPECT_THAT( + [] { asinh(1 / getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { asinh(-1 / getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(asinh(1 + 1 / getTop()).toString(), "0.88137358701954302523260932497979230902816032826163541075329560865337718422202608783370689191025604285673981619210649218876207251197659193752725546276579040922157868036289719624030735740962554897787156326236780650676303289540416355819005952730435167974467341511551586178006392610631334097262572894915748472288200076465594693049140628994381122451738158467277126319460884455255316858936825946495242451691598886050671829540158959591479483197050095772634225707401729190593428412086592318144508722640957213"); EXPECT_EQ(asinh(1 - 1 / getTop()).toString(), @@ -1771,48 +2178,80 @@ TEST(RealFunctionsTests, acoshTest) { EXPECT_EQ(acosh(Real("10000")).toString(), "9.9034875500361280361141978881122997233496952946044950260923836567032304913473953953515725690020423830616528288365523258767489061828343586434808328114258581397841702325146629897292350467756349150430346767665607862477177574083345392634284879969502968285783359747240559839678639708801405512480837902804708295990543604809597201948371269987208380244777001464587545463324020220343935621295486955507859950839246805950189125008128131560856033583621613460499389134966397916170999800412590099260076143420325062"); - EXPECT_THROW(acosh(Real("0")), - UndefinedFunctionException); - EXPECT_THROW(acosh(Real("-1")), - UndefinedFunctionException); - EXPECT_THROW(acosh(Real("0.5")), - UndefinedFunctionException); - EXPECT_THROW(acosh(Real("-0.5")), - UndefinedFunctionException); + EXPECT_THAT( + [] { acosh(Real("0")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { acosh(Real("-1")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { acosh(Real("0.5")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { acosh(Real("-0.5")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(acosh(getBottom()).toString(), "1151.4854435107910205683414683366061078882486418235295386452906200946570972677111974895430572940805839184337371831189543587669560432707084787250541422492825598828384841024609317116054220602947216863597395091146246462156623856213461435584473683581161438305136955387987153590331605537885531891816764680447313482115276519127727666401719754440407634104220773569083968491814130462368341894306482997790282028573331750635353457104910553592436200842481954236838942173940623748983936341728324549070070575813421"); - EXPECT_THROW(acosh(-getBottom()).toString(), - UndefinedFunctionException); - EXPECT_THROW(acosh(1 / getBottom()).toString(), - UndefinedFunctionException); - EXPECT_THROW(acosh(-1 / getBottom()).toString(), - UndefinedFunctionException); + EXPECT_THAT( + [] { acosh(-getBottom()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { acosh(1 / getBottom()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { acosh(-1 / getBottom()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(acosh(1 + 1 / getBottom()).toString(), "1.8161133101249768313059767637749226167016555062135541295428599514579399162477525362449841992214659204923416486740342626879990151285206963843627887984484066329176548338000757254648982552487409334526566762732166521636845007859070742231176086199785002494824233671741808993871471604475449814991979005026904466371335432200684754360612792364909810664574323876073450385968843689808751624105899580384533574694605556028984635741348186918197680661361994642285426418712562403143105149802614347742290494321962424*10^-250"); - EXPECT_THROW(acosh(1 - 1 / getBottom()).toString(), - UndefinedFunctionException); - EXPECT_THROW(acosh(-1 + 1 / getBottom()).toString(), - UndefinedFunctionException); - EXPECT_THROW(acosh(-1 - 1 / getBottom()).toString(), - UndefinedFunctionException); + EXPECT_THAT( + [] { acosh(1 - 1 / getBottom()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { acosh(-1 + 1 / getBottom()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { acosh(-1 - 1 / getBottom()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(acosh(getTop()).toString(), "1152.4854438441245539018176589239077860990037756453300192692944639077298609394752946107525932528960239340920235321102525850798980092830320000555096031215066828506052468765296526295333712752885008572272341663841581776375690972457542070930899079323308648685613749345214020341581518739796542753060280950574892886732978215978223220554397586621190650226114565343493816622827928325467853708568759742433820344125690295321140284116420724299741831747169440212977865955687122877079873810781098497093732339145146"); - EXPECT_THROW(acosh(-getTop()).toString(), - UndefinedFunctionException); - EXPECT_THROW(acosh(1 / getTop()).toString(), - UndefinedFunctionException); - EXPECT_THROW(acosh(-1 / getTop()).toString(), - UndefinedFunctionException); + EXPECT_THAT( + [] { acosh(-getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { acosh(1 / getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { acosh(-1 / getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(acosh(1 + 1 / getTop()).toString(), "1.1015282205148344113031315962232882607549581369854598556825953939712541702951560855963926471275061487735103376848102315248597150700630765059387426235333495755483505788503115382724106804445536940510466695827205469185322984760109337103739057002978598795971390260446685983828095271655143299592980169999703367652156688155730814358165398832394569722569002490431507814481217842691057439436763109599092031344149400752025936592695703741466909450253591955614422574626565454002410396637850800605126854091903233*10^-250"); - EXPECT_THROW(acosh(1 - 1 / getTop()).toString(), - UndefinedFunctionException); - EXPECT_THROW(acosh(-1 + 1 / getTop()).toString(), - UndefinedFunctionException); - EXPECT_THROW(acosh(-1 - 1 / getTop()).toString(), - UndefinedFunctionException); + EXPECT_THAT( + [] { acosh(1 - 1 / getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { acosh(-1 + 1 / getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { acosh(-1 - 1 / getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); } TEST(RealFunctionsTests, atanhTest) { @@ -1829,44 +2268,68 @@ TEST(RealFunctionsTests, atanhTest) { EXPECT_EQ(atanh(Real("-0.5")).toString(), "-0.54930614433405484569762261846126285232374527891137472586734716681874714660930448343680787740686604439398501453297893287118400211296525991052640093538363870530158138459169068358968684942218047995187128515839795576057279595887533567352747008338779011110158512647344878034505326075282143406901815868664928889118349582739606590907451001505191181506112432637409911299554872624544822902673350442298254287422205950942854382374743353980654291470580108306059200070491275719597438444683992471511278657676648427"); - EXPECT_THROW(atanh(Real("-1")), - UndefinedFunctionException); - EXPECT_THROW(atanh(Real("1")), - UndefinedFunctionException); - - EXPECT_THROW(atanh(getBottom()).toString(), - UndefinedFunctionException); - EXPECT_THROW(atanh(-getBottom()).toString(), - UndefinedFunctionException); + EXPECT_THAT( + [] { atanh(Real("-1")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { atanh(Real("1")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + + EXPECT_THAT( + [] { atanh(getBottom()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { atanh(-getBottom()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(atanh(1 / getBottom()).toString(), "1.649133777606550136784218687424004095254941179759911333322637797136168830422634602314115700570892532765885213315763059469571051644237637081484422101463976767747598782769417969433884505005703538555118938103621519633425441890710503685760392630169558339325007093682810777671600073987912657467898712686051207323137042203911162690969426661891984432432828752922861693151232817522147506107429166604238235729862621545138953775084345915962310286003786258852115334834242333756164161942927832989128545815901011*10^-500"); EXPECT_EQ(atanh(-1 / getBottom()).toString(), "-1.649133777606550136784218687424004095254941179759911333322637797136168830422634602314115700570892532765885213315763059469571051644237637081484422101463976767747598782769417969433884505005703538555118938103621519633425441890710503685760392630169558339325007093682810777671600073987912657467898712686051207323137042203911162690969426661891984432432828752922861693151232817522147506107429166604238235729862621545138953775084345915962310286003786258852115334834242333756164161942927832989128545815901011*10^-500"); - EXPECT_THROW(atanh(1 + 1 / getBottom()).toString(), - UndefinedFunctionException); + EXPECT_THAT( + [] { atanh(1 + 1 / getBottom()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(atanh(1 - 1 / getBottom()).toString(), "575.74272175539551028417073416830305394412432091176476932264531004732854863385559874477152864704029195921686859155947717938347802163535423936252707112464127994141924205123046585580271103014736084317986975455731232310783119281067307177922368417905807191525684776939935767951658027689427659459083823402236567410576382595638638332008598772202038170521103867845419842459070652311841709471532414988951410142866658753176767285524552767962181004212409771184194710869703118744919681708641622745350352879067105"); EXPECT_EQ(atanh(-1 + 1 / getBottom()).toString(), "-575.74272175539551028417073416830305394412432091176476932264531004732854863385559874477152864704029195921686859155947717938347802163535423936252707112464127994141924205123046585580271103014736084317986975455731232310783119281067307177922368417905807191525684776939935767951658027689427659459083823402236567410576382595638638332008598772202038170521103867845419842459070652311841709471532414988951410142866658753176767285524552767962181004212409771184194710869703118744919681708641622745350352879067105"); - EXPECT_THROW(atanh(-1 - 1 / getBottom()).toString(), - UndefinedFunctionException); - - EXPECT_THROW(atanh(getTop()).toString(), - UndefinedFunctionException); - EXPECT_THROW(atanh(-getTop()).toString(), - UndefinedFunctionException); - EXPECT_THROW(atanh(1 / getTop()).toString(), - UndefinedFunctionException); - EXPECT_THROW(atanh(-1 / getTop()).toString(), - UndefinedFunctionException); - EXPECT_THROW(atanh(1 + 1 / getTop()).toString(), - UndefinedFunctionException); + EXPECT_THAT( + [] { atanh(-1 - 1 / getBottom()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + + EXPECT_THAT( + [] { atanh(getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { atanh(-getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { atanh(1 / getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { atanh(-1 / getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { atanh(1 + 1 / getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(atanh(1 - 1 / getTop()).toString(), "576.24272192206227695090882946195389304950188782266500963464723195386493046973764730537629662644801196704601176605512629253994900464151600002775480156075334142530262343826482631476668563764425042861361708319207908881878454862287710354654495396616543243428068746726070101707907593698982713765301404752874464433664891079891116102771987933105953251130572826717469083114139641627339268542843798712169101720628451476605701420582103621498709158735847201064889329778435614385399369053905492485468661695725731"); EXPECT_EQ(atanh(-1 + 1 / getTop()).toString(), "-576.24272192206227695090882946195389304950188782266500963464723195386493046973764730537629662644801196704601176605512629253994900464151600002775480156075334142530262343826482631476668563764425042861361708319207908881878454862287710354654495396616543243428068746726070101707907593698982713765301404752874464433664891079891116102771987933105953251130572826717469083114139641627339268542843798712169101720628451476605701420582103621498709158735847201064889329778435614385399369053905492485468661695725731"); - EXPECT_THROW(atanh(-1 - 1 / getTop()).toString(), - UndefinedFunctionException); + EXPECT_THAT( + [] { atanh(-1 - 1 / getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); } TEST(RealFunctionsTests, acothTest) { @@ -1883,44 +2346,70 @@ TEST(RealFunctionsTests, acothTest) { EXPECT_EQ(acoth(Real("-1000000")).toString(), "-1.0000000000003333333333335333333333334761904761905873015873016782106782107551337551338218004218004806239512122391378831007790169926393271392163571860919690829874095283975828022345212989041356330600528686215480517790976833658290967943214330423945771447901567838740949898923463959982926831592832320699731200327474460887158676102648452426732872099468392344630693121604911565633353193154827823840273775285323654539196982943585718028584123194242214521410447558728089475965531459210710507581093455074511807*10^-6"); - EXPECT_THROW(acoth(Real("0")), - UndefinedFunctionException); - EXPECT_THROW(acoth(Real("1")), - UndefinedFunctionException); - EXPECT_THROW(acoth(Real("-1")), - UndefinedFunctionException); + EXPECT_THAT( + [] { acoth(Real("0")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { acoth(Real("1")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { acoth(Real("-1")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(acoth(getBottom()).toString(), "1.649133777606550136784218687424004095254941179759911333322637797136168830422634602314115700570892532765885213315763059469571051644237637081484422101463976767747598782769417969433884505005703538555118938103621519633425441890710503685760392630169558339325007093682810777671600073987912657467898712686051207323137042203911162690969426661891984432432828752922861693151232817522147506107429166604238235729862621545138953775084345915962310286003786258852115334834242333756164161942927832989128545815901011*10^-500"); EXPECT_EQ(acoth(-getBottom()).toString(), "-1.649133777606550136784218687424004095254941179759911333322637797136168830422634602314115700570892532765885213315763059469571051644237637081484422101463976767747598782769417969433884505005703538555118938103621519633425441890710503685760392630169558339325007093682810777671600073987912657467898712686051207323137042203911162690969426661891984432432828752922861693151232817522147506107429166604238235729862621545138953775084345915962310286003786258852115334834242333756164161942927832989128545815901011*10^-500"); - EXPECT_THROW(acoth(1 / getBottom()).toString(), - UndefinedFunctionException); - EXPECT_THROW(acoth(-1 / getBottom()).toString(), - UndefinedFunctionException); + EXPECT_THAT( + [] { acoth(1 / getBottom()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { acoth(-1 / getBottom()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(acoth(1 + 1 / getBottom()).toString(), "575.74272175539551028417073416830305394412432091176476932264531004732854863385559874477152864704029195921686859155947717938347802163535423936252707112464127994141924205123046585580271103014736084317986975455731232310783119281067307177922368417905807191525684776939935767951658027689427659459083823402236567410576382595638638332008598772202038170521103867845419842459070652311841709471532414988951410142866658753176767285524552767962181004212409771184194710869703118744919681708641622745350352879067105"); - EXPECT_THROW(acoth(1 - 1 / getBottom()).toString(), - UndefinedFunctionException); - EXPECT_THROW(acoth(-1 + 1 / getBottom()).toString(), - UndefinedFunctionException); + EXPECT_THAT( + [] { acoth(1 - 1 / getBottom()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { acoth(-1 + 1 / getBottom()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(acoth(-1 - 1 / getBottom()).toString(), "-575.74272175539551028417073416830305394412432091176476932264531004732854863385559874477152864704029195921686859155947717938347802163535423936252707112464127994141924205123046585580271103014736084317986975455731232310783119281067307177922368417905807191525684776939935767951658027689427659459083823402236567410576382595638638332008598772202038170521103867845419842459070652311841709471532414988951410142866658753176767285524552767962181004212409771184194710869703118744919681708641622745350352879067105"); - EXPECT_THROW(acoth(getTop()).toString(), - UndefinedFunctionException); - EXPECT_THROW(acoth(-getTop()).toString(), - UndefinedFunctionException); - EXPECT_THROW(acoth(1 / getTop()).toString(), - UndefinedFunctionException); - EXPECT_THROW(acoth(-1 / getTop()).toString(), - UndefinedFunctionException); + EXPECT_THAT( + [] { acoth(getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { acoth(-getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { acoth(1 / getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { acoth(-1 / getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(acoth(1 + 1 / getTop()).toString(), "576.24272192206227695090882946195389304950188782266500963464723195386493046973764730537629662644801196704601176605512629253994900464151600002775480156075334142530262343826482631476668563764425042861361708319207908881878454862287710354654495396616543243428068746726070101707907593698982713765301404752874464433664891079891116102771987933105953251130572826717469083114139641627339268542843798712169101720628451476605701420582103621498709158735847201064889329778435614385399369053905492485468661695725731"); - EXPECT_THROW(acoth(1 - 1 / getTop()).toString(), - UndefinedFunctionException); - EXPECT_THROW(acoth(-1 + 1 / getTop()).toString(), - UndefinedFunctionException); + EXPECT_THAT( + [] { acoth(1 - 1 / getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { acoth(-1 + 1 / getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(acoth(-1 - 1 / getTop()).toString(), "-576.24272192206227695090882946195389304950188782266500963464723195386493046973764730537629662644801196704601176605512629253994900464151600002775480156075334142530262343826482631476668563764425042861361708319207908881878454862287710354654495396616543243428068746726070101707907593698982713765301404752874464433664891079891116102771987933105953251130572826717469083114139641627339268542843798712169101720628451476605701420582103621498709158735847201064889329778435614385399369053905492485468661695725731"); } @@ -1937,44 +2426,72 @@ TEST(RealFunctionsTests, asechTest) { EXPECT_EQ(asech(Real("0.8")).toString(), "0.69314718055994530941723212145817656807550013436025525412068000949339362196969471560586332699641868754200148102057068573368552023575813055703267075163507596193072757082837143519030703862389167347112335011536449795523912047517268157493206515552473413952588295045300709532636664265410423915781495204374043038550080194417064167151864471283996817178454695702627163106454615025720740248163777338963855069526066834113727387372292895649354702576265209885969320196505855476470330679365443254763274495125040607"); - EXPECT_THROW(asech(Real("0")), - UndefinedFunctionException); - EXPECT_THROW(asech(Real("-1")), - UndefinedFunctionException); - - EXPECT_THROW(asech(getBottom()).toString(), - UndefinedFunctionException); - EXPECT_THROW(asech(-getBottom()).toString(), - UndefinedFunctionException); + EXPECT_THAT( + [] { asech(Real("0")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { asech(Real("-1")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + + EXPECT_THAT( + [] { asech(getBottom()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { asech(-getBottom()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(asech(1 / getBottom()).toString(), "1151.4854435107910205683414683366061078882486418235295386452906200946570972677111974895430572940805839184337371831189543587669560432707084787250541422492825598828384841024609317116054220602947216863597395091146246462156623856213461435584473683581161438305136955387987153590331605537885531891816764680447313482115276519127727666401719754440407634104220773569083968491814130462368341894306482997790282028573331750635353457104910553592436200842481954236838942173940623748983936341728324549070070575813421"); - EXPECT_THROW(asech(-1 / getBottom()).toString(), - UndefinedFunctionException); - EXPECT_THROW(asech(1 + 1 / getBottom()).toString(), - UndefinedFunctionException); + EXPECT_THAT( + [] { asech(-1 / getBottom()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { asech(1 + 1 / getBottom()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(asech(1 - 1 / getBottom()).toString(), "1.8161133101249768313059767637749226167016555062135541295428599514579399162477525362449841992214659204923416486740342626879990151285206963843627887984484066329176548338000757254648982552487409334526566762732166521636845007859070742231176086199785002494824233671741808993871471604475449814991979005026904466371335432200684754360612792364909810664574323876073450385968843689808751624105899580384533574694605556028984635741348186918197680661361994642285426418712562403143105149802614347742290494321962424*10^-250"); - EXPECT_THROW(asech(-1 + 1 / getBottom()).toString(), - UndefinedFunctionException); - EXPECT_THROW(asech(-1 - 1 / getBottom()).toString(), - UndefinedFunctionException); - - EXPECT_THROW(asech(getTop()).toString(), - UndefinedFunctionException); - EXPECT_THROW(asech(-getTop()).toString(), - UndefinedFunctionException); + EXPECT_THAT( + [] { asech(-1 + 1 / getBottom()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { asech(-1 - 1 / getBottom()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + + EXPECT_THAT( + [] { asech(getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { asech(-getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(asech(1 / getTop()).toString(), "1152.4854438441245539018176589239077860990037756453300192692944639077298609394752946107525932528960239340920235321102525850798980092830320000555096031215066828506052468765296526295333712752885008572272341663841581776375690972457542070930899079323308648685613749345214020341581518739796542753060280950574892886732978215978223220554397586621190650226114565343493816622827928325467853708568759742433820344125690295321140284116420724299741831747169440212977865955687122877079873810781098497093732339145146"); - EXPECT_THROW(asech(-1 / getTop()).toString(), - UndefinedFunctionException); - EXPECT_THROW(asech(1 + 1 / getTop()).toString(), - UndefinedFunctionException); + EXPECT_THAT( + [] { asech(-1 / getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { asech(1 + 1 / getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(asech(1 - 1 / getTop()).toString(), "1.1015282205148344113031315962232882607549581369854598556825953939712541702951560855963926471275061487735103376848102315248597150700630765059387426235333495755483505788503115382724106804445536940510466695827205469185322984760109337103739057002978598795971390260446685983828095271655143299592980169999703367652156688155730814358165398832394569722569002490431507814481217842691057439436763109599092031344149400752025936592695703741466909450253591955614422574626565454002410396637850800605126854091903233*10^-250"); - EXPECT_THROW(asech(-1 + 1 / getTop()).toString(), - UndefinedFunctionException); - EXPECT_THROW(asech(-1 - 1 / getTop()).toString(), - UndefinedFunctionException); + EXPECT_THAT( + [] { asech(-1 + 1 / getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { asech(-1 - 1 / getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); } TEST(RealFunctionsTests, acschTest) { @@ -1993,8 +2510,10 @@ TEST(RealFunctionsTests, acschTest) { EXPECT_EQ(acsch(Real("-10")).toString(), "-0.099834078899207563327303124704769443267712911708825010742382695651591768393613465106348449276903206188498406124677873226665835008446207400450999534936293675240929453784224661129186765218330354629955675698152652769815825877645487030185349956435110130012981123752137217672920058387798058093768737175840538375257997368850237548539261911564149546535903638541338513727379764043253416619589358627380617415202311544469434044730284747059064635906989915828599615256664129116822263249491427784753934869133607176"); - EXPECT_THROW(acsch(Real("0")), - UndefinedFunctionException); + EXPECT_THAT( + [] { acsch(Real("0")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(acsch(getBottom()).toString(), "1.649133777606550136784218687424004095254941179759911333322637797136168830422634602314115700570892532765885213315763059469571051644237637081484422101463976767747598782769417969433884505005703538555118938103621519633425441890710503685760392630169558339325007093682810777671600073987912657467898712686051207323137042203911162690969426661891984432432828752922861693151232817522147506107429166604238235729862621545138953775084345915962310286003786258852115334834242333756164161942927832989128545815901011*10^-500"); @@ -2013,10 +2532,14 @@ TEST(RealFunctionsTests, acschTest) { EXPECT_EQ(acsch(-1 - 1 / getBottom()).toString(), "-0.88137358701954302523260932497979230902816032826163541075329560865337718422202608783370689191025604285673981619210649218876207251197659193752725546276579040922157868036289719624030735740962554897787156326236780650676303289540416355819005952730435167974467341511551586178006392610631334097262572894915748472288200076465594693049140628994381122451738158467277126319460884455255316858936825946495242451691598886050671829540158959591479483197050095772634225707401729190593428412086592318144508722640957212"); - EXPECT_THROW(acsch(getTop()).toString(), - UndefinedFunctionException); - EXPECT_THROW(acsch(-getTop()).toString(), - UndefinedFunctionException); + EXPECT_THAT( + [] { acsch(getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { acsch(-getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(acsch(1 / getTop()).toString(), "1152.4854438441245539018176589239077860990037756453300192692944639077298609394752946107525932528960239340920235321102525850798980092830320000555096031215066828506052468765296526295333712752885008572272341663841581776375690972457542070930899079323308648685613749345214020341581518739796542753060280950574892886732978215978223220554397586621190650226114565343493816622827928325467853708568759742433820344125690295321140284116420724299741831747169440212977865955687122877079873810781098497093732339145146"); EXPECT_EQ(acsch(-1 / getTop()).toString(), @@ -2066,26 +2589,44 @@ TEST(RealFunctionsTests, tgammaTest) { EXPECT_EQ(tgamma(Real("-10.888")).toString(), "-3.0005493180448293721869822512345553711440749496581172835311328514510130843563454159410327449904102534962687933580402601136163144286923729599616329109973278889155036400167226010992532533509025591412102006858233580038908845631422707177405401193989133451023586269917939276976357523808049579203927948328610335908936407429428225823028618009800997924455338572712470543931305206282199854307120672911338853112757794177468305728016425719152016898292004791645737323685134147712344090181049164725937814247506367*10^-7"); - EXPECT_THROW(tgamma(Real("0")), - UndefinedFunctionException); - EXPECT_THROW(tgamma(Real("-1")), - UndefinedFunctionException); - EXPECT_THROW(tgamma(Real("-2")), - UndefinedFunctionException); - EXPECT_THROW(tgamma(Real("-3")), - UndefinedFunctionException); - EXPECT_THROW(tgamma(Real("-32352")), - UndefinedFunctionException); - - EXPECT_THROW(tgamma(Real("1000000000")), - UndefinedFunctionException); - EXPECT_THROW(tgamma(Real("-1000000000")), - UndefinedFunctionException); - - EXPECT_THROW(tgamma(getBottom()), - UndefinedFunctionException); - EXPECT_THROW(tgamma(-getBottom()), - UndefinedFunctionException); + EXPECT_THAT( + [] { tgamma(Real("0")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { tgamma(Real("-1")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { tgamma(Real("-2")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { tgamma(Real("-3")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { tgamma(Real("-32352")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + + EXPECT_THAT( + [] { tgamma(Real("1000000000")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { tgamma(Real("-1000000000")); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + + EXPECT_THAT( + [] { tgamma(getBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { tgamma(-getBottom()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(tgamma(1 / getBottom()).toString(), "60637894486118500503636099732462364956850790907849127113254769591568608656948985194787389448417544101315522875333719830559375058059221999457285045467709773208236451195138842541700657594134640809985287947796233555965864294685760448475889927065472080334188866294714585098656713287282618832026757995083776993799896864197894811997715757204066567900975498475027932179243797839056728035498370647887472466931408463051355352585045395714991459137805650231442038783923968764653054533405715475155191362599633532.0"); EXPECT_EQ(tgamma(-1 / getBottom()).toString(), @@ -2099,10 +2640,14 @@ TEST(RealFunctionsTests, tgammaTest) { EXPECT_EQ(tgamma(-1 - 1 / getBottom()).toString(), "60637894486118500503636099732462364956850790907849127113254769591568608656948985194787389448417544101315522875333719830559375058059221999457285045467709773208236451195138842541700657594134640809985287947796233555965864294685760448475889927065472080334188866294714585098656713287282618832026757995083776993799896864197894811997715757204066567900975498475027932179243797839056728035498370647887472466931408463051355352585045395714991459137805650231442038783923968764653054533405715475155191362599633532.0"); - EXPECT_THROW(tgamma(getTop()), - UndefinedFunctionException); - EXPECT_THROW(tgamma(-getTop()).toString(), - UndefinedFunctionException); + EXPECT_THAT( + [] { tgamma(getTop()); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); + EXPECT_THAT( + [] { tgamma(-getTop()).toString(); }, + testing::ThrowsMessage( + testing::StrEq("TODO"))); EXPECT_EQ(tgamma(1 / getTop()).toString(), "1.6483094164130387741510320575015722415830725719070958553581810817964045839732801283320767366433561500407417949917038975822310585763375699419424510422581997424963334554622569199584327881930851555021315633087886023249271483198945434608517539913558850905928096069667671775054328978413933023917511835527377381808000967094899992816840848691527375424965235810613599352178207607112172283212141431574982992000512238522963665692263518204556874384169868120188374052307633082011946880362142902601993503659461819*10^500"); EXPECT_EQ(tgamma(-1 / getTop()).toString(), diff --git a/tests/src/numbers/RealTests.cpp b/tests/src/numbers/RealTests.cpp index 6c7ff7056..36bc68e6f 100644 --- a/tests/src/numbers/RealTests.cpp +++ b/tests/src/numbers/RealTests.cpp @@ -1,3 +1,4 @@ +#include #include #include "fintamath/numbers/Real.hpp" @@ -22,43 +23,117 @@ TEST(RealTests, stringConstructorTest) { EXPECT_EQ(Real(".1").toString(), "0.1"); EXPECT_EQ(Real("1.").toString(), "1.0"); EXPECT_EQ(Real("10000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000").toString(), "1.00000000002*10^94"); + EXPECT_EQ(Real("2*10^2").toString(), "200.0"); EXPECT_EQ(Real("-2*10^2").toString(), "-200.0"); EXPECT_EQ(Real("2*10^-2").toString(), "0.02"); EXPECT_EQ(Real("-2*10^-2").toString(), "-0.02"); + EXPECT_EQ(Real("2*10^0").toString(), "2.0"); + EXPECT_EQ(Real("-2*10^0").toString(), "-2.0"); + + EXPECT_EQ(Real("0*10^2").toString(), "0.0"); + EXPECT_EQ(Real("0*10^-2").toString(), "0.0"); + EXPECT_EQ(Real("0*10^0").toString(), "0.0"); + EXPECT_EQ(Real("123.456*10^1000").toString(), "1.23456*10^1002"); EXPECT_EQ(Real("-123.456*10^1000").toString(), "-1.23456*10^1002"); EXPECT_EQ(Real("123.456*10^-1000").toString(), "1.23456*10^-998"); EXPECT_EQ(Real("-123.456*10^-1000").toString(), "-1.23456*10^-998"); + EXPECT_EQ(Real("123.456*10^0").toString(), "123.456"); + EXPECT_EQ(Real("-123.456*10^0").toString(), "-123.456"); + EXPECT_EQ(Real("0.123456*10^1000").toString(), "1.23456*10^999"); EXPECT_EQ(Real("-0.123456*10^1000").toString(), "-1.23456*10^999"); EXPECT_EQ(Real("0.123456*10^-1000").toString(), "1.23456*10^-1001"); EXPECT_EQ(Real("-0.123456*10^-1000").toString(), "-1.23456*10^-1001"); - - EXPECT_THROW(Real("--10"), InvalidInputException); - EXPECT_THROW(Real("test"), InvalidInputException); - EXPECT_THROW(Real(""), InvalidInputException); - EXPECT_THROW(Real("+"), InvalidInputException); - EXPECT_THROW(Real("939849.0-0023"), InvalidInputException); - EXPECT_THROW(Real("a"), InvalidInputException); - EXPECT_THROW(Real("a.1"), InvalidInputException); - EXPECT_THROW(Real("1.a"), InvalidInputException); - EXPECT_THROW(Real("1a.1"), InvalidInputException); - EXPECT_THROW(Real("1.1a"), InvalidInputException); - EXPECT_THROW(Real("--10.-1"), InvalidInputException); - EXPECT_THROW(Real("10.-1"), InvalidInputException); - EXPECT_THROW(Real("1-0.1"), InvalidInputException); - EXPECT_THROW(Real("10-.1"), InvalidInputException); - EXPECT_THROW(Real("10.--1"), InvalidInputException); - EXPECT_THROW(Real("."), InvalidInputException); - EXPECT_THROW(Real("1.2.1"), InvalidInputException); - EXPECT_THROW(Real("2*10^2.2"), InvalidInputException); - EXPECT_THROW(Real("0*10^0"), InvalidInputException); - - EXPECT_THROW(Real("10*10^100000000000000000000"), UndefinedException); + EXPECT_EQ(Real("0.123456*10^0").toString(), "0.123456"); + EXPECT_EQ(Real("-0.123456*10^0").toString(), "-0.123456"); + + EXPECT_THAT( + [] { Real(""); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Real from "")"))); + EXPECT_THAT( + [] { Real("--10"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Real from "--10")"))); + EXPECT_THAT( + [] { Real("test"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Real from "test")"))); + EXPECT_THAT( + [] { Real("+"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Real from "+")"))); + EXPECT_THAT( + [] { Real("939849.0-0023"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Real from "939849.0-0023")"))); + EXPECT_THAT( + [] { Real("a"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Real from "a")"))); + EXPECT_THAT( + [] { Real("a.1"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Real from "a.1")"))); + EXPECT_THAT( + [] { Real("1.a"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Real from "1.a")"))); + EXPECT_THAT( + [] { Real("1a.1"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Real from "1a.1")"))); + EXPECT_THAT( + [] { Real("1.1a"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Real from "1.1a")"))); + EXPECT_THAT( + [] { Real("--10.-1"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Real from "--10.-1")"))); + EXPECT_THAT( + [] { Real("10.-1"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Real from "10.-1")"))); + EXPECT_THAT( + [] { Real("1-0.1"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Real from "1-0.1")"))); + EXPECT_THAT( + [] { Real("10-.1"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Real from "10-.1")"))); + EXPECT_THAT( + [] { Real("10.--1"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Real from "10.--1")"))); + EXPECT_THAT( + [] { Real("."); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Real from ".")"))); + EXPECT_THAT( + [] { Real("1.2.1"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Real from "1.2.1")"))); + EXPECT_THAT( + [] { Real("2*10^2.2"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Real from "2*10^2.2")"))); + EXPECT_THAT( + [] { Real("2*10^-2.2"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Unable to parse Real from "2*10^-2.2")"))); + + EXPECT_THAT( + [] { Real("10*10^100000000000000000000"); }, + testing::ThrowsMessage( + testing::StrEq(R"(Undefined "10*10^100000000000000000000" (overflow))"))); } TEST(RealTests, rationalConstructorTest) { + EXPECT_EQ(Real(Rational(0)).toString(), "0.0"); EXPECT_EQ(Real(Rational(2, 5)).toString(), "0.4"); EXPECT_EQ(Real(Rational(-2, 5)).toString(), "-0.4"); EXPECT_EQ(Real(Rational(30, 10)).toString(), "3.0"); @@ -73,8 +148,11 @@ TEST(RealTests, rationalAssignmentOperatorConstructorTest) { } TEST(RealTests, integerConstructorTest) { + EXPECT_EQ(Real(Integer(0)).toString(), "0.0"); EXPECT_EQ(Real(Integer(2)).toString(), "2.0"); + EXPECT_EQ(Real(Integer(-2)).toString(), "-2.0"); EXPECT_EQ(Real(Integer(10)).toString(), "10.0"); + EXPECT_EQ(Real(Integer(-10)).toString(), "-10.0"); } TEST(RealTests, integerAssignmentOperatorTest) { diff --git a/thirdparty/boost-config b/thirdparty/boost-config new file mode 160000 index 000000000..cbeca533d --- /dev/null +++ b/thirdparty/boost-config @@ -0,0 +1 @@ +Subproject commit cbeca533d2113efbcffa84326111ad15a6a1f57a diff --git a/thirdparty/boost-container-hash b/thirdparty/boost-container-hash new file mode 160000 index 000000000..48a306dcf --- /dev/null +++ b/thirdparty/boost-container-hash @@ -0,0 +1 @@ +Subproject commit 48a306dcf236ae460d9ba55648d449ed7bea1dee diff --git a/thirdparty/boost-describe b/thirdparty/boost-describe new file mode 160000 index 000000000..c89e4dd3d --- /dev/null +++ b/thirdparty/boost-describe @@ -0,0 +1 @@ +Subproject commit c89e4dd3db81eb4f2867b2bc965d161f51cc316c diff --git a/thirdparty/boost-mp11 b/thirdparty/boost-mp11 new file mode 160000 index 000000000..391e23ae7 --- /dev/null +++ b/thirdparty/boost-mp11 @@ -0,0 +1 @@ +Subproject commit 391e23ae716aec4d59f6c7272e49e1dd8c01dcdb