Skip to content

Commit

Permalink
Fix ODR violations in tests
Browse files Browse the repository at this point in the history
CMake builds all tests into a single executable. So, naming these two
classes the same is an ODR violation, which also causes segmentation
fault on my machine when I try to run tests.

With this patch, test executable do not crash anymore. However, there
are still 13 failing tests, which require further investigation.
  • Loading branch information
DanShaders committed Oct 9, 2023
1 parent ab7c254 commit 9e7b3a4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/GraphicsPathParser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace internal {
}

template <>
bool parse_number (std::istream &is, double &value) {
inline bool parse_number (std::istream &is, double &value) {
// don't use operator >> for parsing floating point values because it's implemented
// differently in libstdc++ and libc++. Instead, use our own function to read the
// value from the input stream.
Expand Down
4 changes: 2 additions & 2 deletions tests/TensorProductPatchTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ TEST_F(TensorProductPatchTest, bbox) {
}


class Callback : public ShadingPatch::Callback {
class TensorProductPatchTestCallback : public ShadingPatch::Callback {
public:
void patchSegment (GraphicsPath<double> &path, const Color &color) {
ostringstream oss;
Expand All @@ -284,7 +284,7 @@ class Callback : public ShadingPatch::Callback {


TEST_F(TensorProductPatchTest, approximate) {
Callback callback;
TensorProductPatchTestCallback callback;
vector<Color> colors(4);
TensorProductPatch tpp(_points, colors, Color::ColorSpace::RGB, 0, 0);
tpp.approximate(2, false, 0.1, callback);
Expand Down
4 changes: 2 additions & 2 deletions tests/TriangularPatchTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ TEST(TriangularPatchTest, boundaryPath) {
}


class Callback : public ShadingPatch::Callback {
class TriangularPatchTestCallback : public ShadingPatch::Callback {
public:
void patchSegment (GraphicsPath<double> &path, const Color &color) {
ostringstream oss;
Expand All @@ -167,7 +167,7 @@ TEST(TriangularPatchTest, approximate) {
points[2] = DPair(0, 10);
vector<Color> colors(3);
TriangularPatch tp(points, colors, Color::ColorSpace::RGB, 0, 0);
Callback callback;
TriangularPatchTestCallback callback;
tp.approximate(2, false, 0.1, callback);
EXPECT_EQ(callback.pathstr(), "M0 0H10L0 10Z");
EXPECT_EQ(callback.colorstr(), "#000");
Expand Down

0 comments on commit 9e7b3a4

Please sign in to comment.