Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dmitri Naumov
ogs
Commits
532e0aa2
Commit
532e0aa2
authored
5 years ago
by
Dmitri Naumov
Browse files
Options
Downloads
Patches
Plain Diff
[T/GL] Use unique_ptrs to avoid potential mem leak
parent
c6b92702
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Tests/GeoLib/TestPointVec.cpp
+11
-21
11 additions, 21 deletions
Tests/GeoLib/TestPointVec.cpp
with
11 additions
and
21 deletions
Tests/GeoLib/TestPointVec.cpp
+
11
−
21
View file @
532e0aa2
...
@@ -58,11 +58,9 @@ TEST_F(PointVecTest, TestPointVecCtorSinglePoint)
...
@@ -58,11 +58,9 @@ TEST_F(PointVecTest, TestPointVecCtorSinglePoint)
{
{
auto
ps_ptr
=
std
::
make_unique
<
VectorOfPoints
>
();
auto
ps_ptr
=
std
::
make_unique
<
VectorOfPoints
>
();
ps_ptr
->
push_back
(
new
GeoLib
::
Point
(
0
,
0
,
0
,
0
));
ps_ptr
->
push_back
(
new
GeoLib
::
Point
(
0
,
0
,
0
,
0
));
GeoLib
::
PointVec
*
point_vec
=
nullptr
;
auto
point_vec
=
point_vec
=
new
GeoLib
::
PointVec
(
name
,
std
::
move
(
ps_ptr
));
std
::
make_unique
<
GeoLib
::
PointVec
>
(
name
,
std
::
move
(
ps_ptr
));
ASSERT_EQ
(
std
::
size_t
(
1
),
point_vec
->
size
());
ASSERT_EQ
(
std
::
size_t
(
1
),
point_vec
->
size
());
delete
point_vec
;
}
}
// Testing input vector with two different points.
// Testing input vector with two different points.
...
@@ -72,11 +70,9 @@ TEST_F(PointVecTest, TestPointVecCtorTwoDiffPoints)
...
@@ -72,11 +70,9 @@ TEST_F(PointVecTest, TestPointVecCtorTwoDiffPoints)
ps_ptr
->
push_back
(
new
GeoLib
::
Point
(
0
,
0
,
0
,
0
));
ps_ptr
->
push_back
(
new
GeoLib
::
Point
(
0
,
0
,
0
,
0
));
ps_ptr
->
push_back
(
new
GeoLib
::
Point
(
1
,
0
,
0
,
1
));
ps_ptr
->
push_back
(
new
GeoLib
::
Point
(
1
,
0
,
0
,
1
));
GeoLib
::
PointVec
*
point_vec
=
nullptr
;
auto
point_vec
=
point_vec
=
new
GeoLib
::
PointVec
(
name
,
std
::
move
(
ps_ptr
));
std
::
make_unique
<
GeoLib
::
PointVec
>
(
name
,
std
::
move
(
ps_ptr
));
ASSERT_EQ
(
std
::
size_t
(
2
),
point_vec
->
size
());
ASSERT_EQ
(
std
::
size_t
(
2
),
point_vec
->
size
());
delete
point_vec
;
}
}
// Testing input vector with two equal points.
// Testing input vector with two equal points.
...
@@ -86,11 +82,9 @@ TEST_F(PointVecTest, TestPointVecCtorTwoEqualPoints)
...
@@ -86,11 +82,9 @@ TEST_F(PointVecTest, TestPointVecCtorTwoEqualPoints)
ps_ptr
->
push_back
(
new
GeoLib
::
Point
(
0
,
0
,
0
,
0
));
ps_ptr
->
push_back
(
new
GeoLib
::
Point
(
0
,
0
,
0
,
0
));
ps_ptr
->
push_back
(
new
GeoLib
::
Point
(
0
,
0
,
0
,
1
));
ps_ptr
->
push_back
(
new
GeoLib
::
Point
(
0
,
0
,
0
,
1
));
GeoLib
::
PointVec
*
point_vec
=
nullptr
;
auto
point_vec
=
point_vec
=
new
GeoLib
::
PointVec
(
name
,
std
::
move
(
ps_ptr
));
std
::
make_unique
<
GeoLib
::
PointVec
>
(
name
,
std
::
move
(
ps_ptr
));
ASSERT_EQ
(
std
::
size_t
(
1
),
point_vec
->
size
());
ASSERT_EQ
(
std
::
size_t
(
1
),
point_vec
->
size
());
delete
point_vec
;
}
}
// Testing input vector with single point.
// Testing input vector with single point.
...
@@ -188,19 +182,15 @@ TEST_F(PointVecTest, TestPointVecCtorRandomPoints)
...
@@ -188,19 +182,15 @@ TEST_F(PointVecTest, TestPointVecCtorRandomPoints)
auto
ps_ptr
=
std
::
make_unique
<
VectorOfPoints
>
();
auto
ps_ptr
=
std
::
make_unique
<
VectorOfPoints
>
();
generateRandomPoints
(
*
ps_ptr
,
10000
);
generateRandomPoints
(
*
ps_ptr
,
10000
);
GeoLib
::
PointVec
*
point_vec
=
nullptr
;
auto
point_vec
=
point_vec
=
new
GeoLib
::
PointVec
(
name
,
std
::
move
(
ps_ptr
));
std
::
make_unique
<
GeoLib
::
PointVec
>
(
name
,
std
::
move
(
ps_ptr
));
delete
point_vec
;
}
}
TEST_F
(
PointVecTest
,
TestPointVecCtorRandomPointsLargeEps
)
TEST_F
(
PointVecTest
,
TestPointVecCtorRandomPointsLargeEps
)
{
{
auto
ps_ptr
=
std
::
make_unique
<
VectorOfPoints
>
();
auto
ps_ptr
=
std
::
make_unique
<
VectorOfPoints
>
();
generateRandomPoints
(
*
ps_ptr
,
10000
);
generateRandomPoints
(
*
ps_ptr
,
10000
);
GeoLib
::
PointVec
*
point_vec
=
nullptr
;
auto
point_vec
=
std
::
make_unique
<
GeoLib
::
PointVec
>
(
point_vec
=
new
GeoLib
::
PointVec
(
name
,
std
::
move
(
ps_ptr
),
name
,
std
::
move
(
ps_ptr
),
nullptr
,
GeoLib
::
PointVec
::
PointType
::
POINT
,
nullptr
,
GeoLib
::
PointVec
::
PointType
::
POINT
,
1e-2
);
1e-2
);
delete
point_vec
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment