Skip to content
Snippets Groups Projects
Commit d9e3f5c9 authored by Tom Fischer's avatar Tom Fischer
Browse files

Merge pull request #745 from endJunction/FixMemoryLeaksGeoLibTests

Fix memory leaks geo lib tests
parents 0e3affe5 9bdd8c0a
No related branches found
No related tags found
No related merge requests found
......@@ -200,6 +200,9 @@ TEST(GeoLib, AABBAllPointsWithNegativeCoordinatesI)
ASSERT_NEAR(-1.0, max_pnt[0], std::numeric_limits<double>::epsilon());
ASSERT_NEAR(-1.0, max_pnt[1], std::numeric_limits<double>::epsilon());
ASSERT_NEAR(-1.0, max_pnt[2], std::numeric_limits<double>::epsilon());
for (auto p : pnts)
delete p;
}
TEST(GeoLib, AABBAllPointsWithNegativeCoordinatesII)
......
......@@ -113,8 +113,11 @@ TEST(GeoLib, TestBoundingSphere)
}
/// Calculates the bounding sphere of points on a bounding sphere
std::vector<MathLib::Point3d*> *sphere_points (s.getRandomSpherePoints(1000));
auto sphere_points = std::unique_ptr<
std::vector<MathLib::Point3d*>>(s.getRandomSpherePoints(1000));
GeoLib::MinimalBoundingSphere t(*sphere_points);
for (auto p : *sphere_points)
delete p;
MathLib::Point3d center = s.getCenter();
ASSERT_NEAR(0.5, center[0], std::numeric_limits<double>::epsilon());
ASSERT_NEAR(0.5, center[1], std::numeric_limits<double>::epsilon());
......
......@@ -12,6 +12,15 @@
#include "gtest/gtest.h"
#include "AnalyticalGeometry.h"
auto test3equal = [](double a, double b, double c, double const* result)
{
EXPECT_EQ(a, result[0]);
EXPECT_EQ(b, result[1]);
EXPECT_EQ(c, result[2]);
delete[] result;
};
TEST(GeoLib, ComputeRotationMatrixToXYnegative)
{
MathLib::Vector3 const n(0.0, -1.0, 0.0);
......@@ -29,22 +38,13 @@ TEST(GeoLib, ComputeRotationMatrixToXYnegative)
EXPECT_EQ(0.0, rot_mat(2,2));
MathLib::Vector3 const x(0.0,1.0,0.0);
MathLib::Vector3 const result(rot_mat*x.getCoords());
EXPECT_EQ(0.0, result[0]);
EXPECT_EQ(0.0, result[1]);
EXPECT_EQ(-1.0, result[2]);
test3equal(0, 0, -1, rot_mat*x.getCoords());
MathLib::Vector3 const x0(10.0,1.0,0.0);
MathLib::Vector3 const r0(rot_mat*x0.getCoords());
EXPECT_EQ(10.0, r0[0]);
EXPECT_EQ(0.0, r0[1]);
EXPECT_EQ(-1.0, r0[2]);
test3equal(10, 0, -1, rot_mat*x0.getCoords());
MathLib::Vector3 const x1(10.0,0.0,10.0);
MathLib::Vector3 const r1(rot_mat*x1.getCoords());
EXPECT_EQ(10.0, r1[0]);
EXPECT_EQ(10.0, r1[1]);
EXPECT_EQ(0.0, r1[2]);
test3equal(10, 10, 0, rot_mat*x1.getCoords());
}
TEST(GeoLib, ComputeRotationMatrixToXYpositive)
......@@ -64,21 +64,12 @@ TEST(GeoLib, ComputeRotationMatrixToXYpositive)
EXPECT_EQ(0.0, rot_mat(2,2));
MathLib::Vector3 const x(0.0,1.0,0.0);
MathLib::Vector3 const result(rot_mat*x.getCoords());
EXPECT_EQ(0.0, result[0]);
EXPECT_EQ(0.0, result[1]);
EXPECT_EQ(1.0, result[2]);
test3equal(0, 0, 1, rot_mat*x.getCoords());
MathLib::Vector3 const x0(10.0,1.0,0.0);
MathLib::Vector3 const r0(rot_mat*x0.getCoords());
EXPECT_EQ(10.0, r0[0]);
EXPECT_EQ(0.0, r0[1]);
EXPECT_EQ(1.0, r0[2]);
test3equal(10, 0, 1, rot_mat*x0.getCoords());
MathLib::Vector3 const x1(10.0,0.0,10.0);
MathLib::Vector3 const r1(rot_mat*x1.getCoords());
EXPECT_EQ(10.0, r1[0]);
EXPECT_EQ(-10.0, r1[1]);
EXPECT_EQ(0.0, r1[2]);
test3equal(10, -10, 0, rot_mat*x1.getCoords());
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment