diff --git a/include/fintamath/core/IMathObject.hpp b/include/fintamath/core/IMathObject.hpp index 17ab94ecb..271c3befd 100644 --- a/include/fintamath/core/IMathObject.hpp +++ b/include/fintamath/core/IMathObject.hpp @@ -1,11 +1,14 @@ #pragma once #include +#include #include #include #include #include +#include + #include "fintamath/core/Converter.hpp" #include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/MathObjectTypes.hpp" @@ -24,7 +27,7 @@ class IMathObject { virtual std::unique_ptr clone() && = 0; virtual std::string toString() const { - return typeid(*this).name(); + return fmt::format("MathObject{}", static_cast(getType())); } virtual std::unique_ptr toMinimalObject() const { diff --git a/tests/src/core/IMathObjectTests.cpp b/tests/src/core/IMathObjectTests.cpp index 4345ce642..d8875f56a 100644 --- a/tests/src/core/IMathObjectTests.cpp +++ b/tests/src/core/IMathObjectTests.cpp @@ -10,12 +10,17 @@ using namespace fintamath; namespace { -class TestMathObject final : public IMathObjectCRTP {}; +class TestMathObject final : public IMathObjectCRTP { +public: + static constexpr MathObjectType getTypeStatic() { + return static_cast(MathObjectType::IMathObject) + 999; + } +}; } TEST(IMathObjectTests, toStringTest) { - EXPECT_EQ(TestMathObject().toString(), typeid(TestMathObject).name()); + EXPECT_EQ(TestMathObject().toString(), "MathObject999"); } TEST(IMathObjectTests, cloneTest) {