Skip to content

Commit

Permalink
Remove std::string conversions from Point and Vector
Browse files Browse the repository at this point in the history
This allows the removal of the `<string>` include.
  • Loading branch information
DanRStevens committed Mar 8, 2025
1 parent 1f79e57 commit 0fbfde1
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 26 deletions.
7 changes: 0 additions & 7 deletions NAS2D/Math/Point.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

#include "Vector.h"

#include <string>


namespace NAS2D
{
Expand Down Expand Up @@ -84,11 +82,6 @@ namespace NAS2D
{
return Point<NewBaseType>(*this);
}

explicit operator std::string() const
{
return "(" + std::to_string(x) + ", " + std::to_string(y) + ")";
}
};


Expand Down
7 changes: 0 additions & 7 deletions NAS2D/Math/Vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

#include "IsZero.h"

#include <string>


namespace NAS2D
{
Expand Down Expand Up @@ -125,11 +123,6 @@ namespace NAS2D
{
return Vector<NewBaseType>(*this);
}

explicit operator std::string() const
{
return "(" + std::to_string(x) + ", " + std::to_string(y) + ")";
}
};


Expand Down
6 changes: 0 additions & 6 deletions test/Math/Point.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,6 @@ TEST(Point, to) {
EXPECT_EQ((NAS2D::Point<float>{1.0, 2.0}), (NAS2D::Point<int>{1, 2}.to<float>()));
}

TEST(Point, stringConversion) {
EXPECT_EQ("(0, 0)", (std::string{NAS2D::Point{0, 0}}));
EXPECT_EQ("(1, 0)", (std::string{NAS2D::Point{1, 0}}));
EXPECT_EQ("(0, 1)", (std::string{NAS2D::Point{0, 1}}));
}

TEST(Point, VectorPointAdd) {
EXPECT_EQ((NAS2D::Point{2, 3}), (NAS2D::Vector{1, 2} + NAS2D::Point<int>{1, 1}));
}
Expand Down
6 changes: 0 additions & 6 deletions test/Math/Vector.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,6 @@ TEST(Vector, to) {
EXPECT_EQ((NAS2D::Vector<float>{1.0, 2.0}), (NAS2D::Vector<int>{1, 2}.to<float>()));
}

TEST(Vector, stringConversion) {
EXPECT_EQ("(0, 0)", (std::string{NAS2D::Vector{0, 0}}));
EXPECT_EQ("(1, 0)", (std::string{NAS2D::Vector{1, 0}}));
EXPECT_EQ("(0, 1)", (std::string{NAS2D::Vector{0, 1}}));
}

TEST(Vector, scalarVectorMultiply) {
EXPECT_EQ((NAS2D::Vector{2, 4}), (2 * NAS2D::Vector{1, 2}));
}
Expand Down

0 comments on commit 0fbfde1

Please sign in to comment.