From ba86ae85bc7f42ff299364c63f57ab5dfa09ef50 Mon Sep 17 00:00:00 2001 From: fintarin Date: Mon, 19 Feb 2024 20:14:04 +0300 Subject: [PATCH] a --- include/fintamath/core/MathObjectBoundTypes.hpp | 2 ++ include/fintamath/exceptions/Exception.hpp | 4 ++-- include/fintamath/exceptions/InvalidInputException.hpp | 4 ++-- include/fintamath/exceptions/UndefinedException.hpp | 4 ++-- src/fintamath/literals/Variable.cpp | 6 +++--- src/fintamath/numbers/Real.cpp | 2 +- tests/src/literals/VariableTests.cpp | 8 ++++---- 7 files changed, 16 insertions(+), 14 deletions(-) diff --git a/include/fintamath/core/MathObjectBoundTypes.hpp b/include/fintamath/core/MathObjectBoundTypes.hpp index 3e17ba8de..fa7e73ff1 100644 --- a/include/fintamath/core/MathObjectBoundTypes.hpp +++ b/include/fintamath/core/MathObjectBoundTypes.hpp @@ -1,6 +1,8 @@ #pragma once +#include #include +#include #include "fintamath/core/MathObjectType.hpp" diff --git a/include/fintamath/exceptions/Exception.hpp b/include/fintamath/exceptions/Exception.hpp index fbbdae166..31cef1649 100644 --- a/include/fintamath/exceptions/Exception.hpp +++ b/include/fintamath/exceptions/Exception.hpp @@ -2,13 +2,13 @@ #include #include -#include +#include namespace fintamath { class Exception : public std::exception { public: - explicit Exception(const std::string_view inMessage) : message(inMessage) { + explicit Exception(std::string inMessage) : message(std::move(inMessage)) { } const char *what() const noexcept override { diff --git a/include/fintamath/exceptions/InvalidInputException.hpp b/include/fintamath/exceptions/InvalidInputException.hpp index e526bbeea..0b48cafcf 100644 --- a/include/fintamath/exceptions/InvalidInputException.hpp +++ b/include/fintamath/exceptions/InvalidInputException.hpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include "fintamath/exceptions/Exception.hpp" @@ -10,7 +10,7 @@ namespace fintamath { class InvalidInputException : public Exception { public: - explicit InvalidInputException(const std::string_view inMessage) : Exception(inMessage) { + explicit InvalidInputException(std::string inMessage) : Exception(std::move(inMessage)) { } }; diff --git a/include/fintamath/exceptions/UndefinedException.hpp b/include/fintamath/exceptions/UndefinedException.hpp index 95e90a55d..b135a563b 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,7 +10,7 @@ namespace fintamath { class UndefinedException : public Exception { public: - explicit UndefinedException(const std::string_view inMessage) : Exception(inMessage) { + explicit UndefinedException(std::string inMessage) : Exception(std::move(inMessage)) { } }; diff --git a/src/fintamath/literals/Variable.cpp b/src/fintamath/literals/Variable.cpp index 211867dc6..bcb1ec702 100644 --- a/src/fintamath/literals/Variable.cpp +++ b/src/fintamath/literals/Variable.cpp @@ -14,12 +14,12 @@ namespace fintamath { Variable::Variable(const std::string_view inName) { if (inName.size() != 1) { throw InvalidInputException( - fmt::format(R"(Invalid {} "{}" (name expected to be 1 character))", getTypeStatic().getName(), inName)); + fmt::format(R"(Invalid {} name "{}" (expected a 1 character))", getTypeStatic().getName(), inName)); } if (const char ch = inName.front(); ch < 'a' || ch > 'z') { throw InvalidInputException( - fmt::format(R"(Invalid {} "{}" (name expected to be an English lowercase letter))", getTypeStatic().getName(), inName)); + fmt::format(R"(Invalid {} name "{}" (expected an English lowercase letter))", getTypeStatic().getName(), inName)); } name = std::string(inName); @@ -28,7 +28,7 @@ Variable::Variable(const std::string_view inName) { Variable::Variable(const std::string_view inName, Integer inIndex) : Variable(inName) { if (inIndex < 0) { throw InvalidInputException( - fmt::format(R"(Invalid {} "{}_{}" (expected index >= 0))", getTypeStatic().getName(), name, inIndex.toString())); + fmt::format(R"(Invalid {} index "{}" (expected >= 0))", getTypeStatic().getName(), inIndex.toString())); } index = std::move(inIndex); diff --git a/src/fintamath/numbers/Real.cpp b/src/fintamath/numbers/Real.cpp index 8f557239b..8efa77092 100644 --- a/src/fintamath/numbers/Real.cpp +++ b/src/fintamath/numbers/Real.cpp @@ -253,7 +253,7 @@ void Real::updatePrecision(const Real &rhs) { void Real::validateNewPrecision(const unsigned precision) const { if (precision > outputPrecision) { - throw InvalidInputException(fmt::format("Invalid precision {} (expected precision <= {})", precision, outputPrecision)); + throw InvalidInputException(fmt::format("Invalid precision {} (expected <= {})", precision, outputPrecision)); } } diff --git a/tests/src/literals/VariableTests.cpp b/tests/src/literals/VariableTests.cpp index c7376ee64..b81b73f2c 100644 --- a/tests/src/literals/VariableTests.cpp +++ b/tests/src/literals/VariableTests.cpp @@ -82,14 +82,14 @@ TEST(VariableTest, stringIntegerConstructorTest) { testing::ThrowsMessage( testing::StrEq(R"(Invalid Variable "|" (name expected to be an English lowercase letter))"))); - EXPECT_THAT( - [] { Variable("A", 1); }, - testing::ThrowsMessage( - testing::StrEq(R"(Invalid Variable "A" (name expected to be an English lowercase letter))"))); EXPECT_THAT( [] { Variable("ab", 1); }, testing::ThrowsMessage( testing::StrEq(R"(Invalid Variable "ab" (name expected to be 1 character))"))); + EXPECT_THAT( + [] { Variable("A", 1); }, + testing::ThrowsMessage( + testing::StrEq(R"(Invalid Variable "A" (name expected to be an English lowercase letter))"))); EXPECT_THAT( [] { Variable("a", -1); }, testing::ThrowsMessage(