Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenVolumeMesh
OpenVolumeMesh
Commits
854c2dfd
Commit
854c2dfd
authored
Feb 18, 2019
by
Martin Heistermann
Browse files
unittests: avoid deprecated size_t property indexing.
parent
cd7ad95d
Pipeline
#8628
passed with stage
in 4 minutes and 6 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/Unittests/unittests_basics.cc
View file @
854c2dfd
...
...
@@ -682,20 +682,20 @@ TEST_F(PolyhedralMeshBase, PolyhedralMeshProperties) {
EXPECT_TRUE
(
mesh_
.
vertex_property_exists
<
Vec3d
>
(
"VProp"
));
for
(
VertexIter
v_it
=
mesh_
.
v_iter
();
v_it
.
valid
();
++
v_it
)
{
vp
[
v_it
->
idx
()
]
=
Vec3d
(
1.0
,
0.0
,
0.0
);
vp
[
*
v_it
]
=
Vec3d
(
1.0
,
0.0
,
0.0
);
}
for
(
VertexIter
v_it
=
mesh_
.
v_iter
();
v_it
.
valid
();
++
v_it
)
{
Vec3d
t
;
t
=
vp
[
v_it
->
idx
()
];
t
=
vp
[
*
v_it
];
EXPECT_DOUBLE_EQ
(
1.0
,
t
[
0
]);
EXPECT_DOUBLE_EQ
(
0.0
,
t
[
1
]);
EXPECT_DOUBLE_EQ
(
0.0
,
t
[
2
]);
}
VertexHandle
vh
=
mesh_
.
add_vertex
(
Vec3d
(
3.0
,
3.0
,
3.0
));
vp
[
vh
.
idx
()
]
=
Vec3d
(
0.0
);
Vec3d
p
=
vp
[
vh
.
idx
()
];
vp
[
vh
]
=
Vec3d
(
0.0
);
Vec3d
p
=
vp
[
vh
];
EXPECT_DOUBLE_EQ
(
0.0
,
p
[
0
]);
EXPECT_DOUBLE_EQ
(
0.0
,
p
[
1
]);
EXPECT_DOUBLE_EQ
(
0.0
,
p
[
2
]);
...
...
@@ -706,12 +706,12 @@ TEST_F(PolyhedralMeshBase, PolyhedralMeshProperties) {
unsigned
int
i
=
0
;
for
(
EdgeIter
e_it
=
mesh_
.
e_iter
();
e_it
.
valid
();
++
e_it
)
{
ep
[
e_it
->
idx
()
]
=
i
++
;
ep
[
*
e_it
]
=
i
++
;
}
i
=
0
;
for
(
EdgeIter
e_it
=
mesh_
.
e_iter
();
e_it
.
valid
();
++
e_it
)
{
EXPECT_EQ
(
i
++
,
ep
[
e_it
->
idx
()
]);
EXPECT_EQ
(
i
++
,
ep
[
*
e_it
]);
}
HalfFacePropertyT
<
bool
>
hfp
=
mesh_
.
request_halfface_property
<
bool
>
(
"HFProp"
);
...
...
@@ -720,13 +720,13 @@ TEST_F(PolyhedralMeshBase, PolyhedralMeshProperties) {
bool
b
=
false
;
for
(
HalfFaceIter
hf_it
=
mesh_
.
hf_iter
();
hf_it
.
valid
();
++
hf_it
)
{
hfp
[
hf_it
->
idx
()
]
=
b
;
hfp
[
*
hf_it
]
=
b
;
b
=
!
b
;
}
b
=
false
;
for
(
HalfFaceIter
hf_it
=
mesh_
.
hf_iter
();
hf_it
.
valid
();
++
hf_it
)
{
EXPECT_EQ
(
b
,
hfp
[
hf_it
->
idx
()
]);
EXPECT_EQ
(
b
,
hfp
[
*
hf_it
]);
b
=
!
b
;
}
...
...
@@ -736,11 +736,11 @@ TEST_F(PolyhedralMeshBase, PolyhedralMeshProperties) {
EXPECT_TRUE
(
mesh_
.
cell_property_exists
<
std
::
string
>
(
"CProp"
));
for
(
CellIter
c_it
=
mesh_
.
c_iter
();
c_it
.
valid
();
++
c_it
)
{
cp
[
c_it
->
idx
()
]
=
std
::
string
(
"MyTestString"
);
cp
[
*
c_it
]
=
std
::
string
(
"MyTestString"
);
}
for
(
CellIter
c_it
=
mesh_
.
c_iter
();
c_it
.
valid
();
++
c_it
)
{
EXPECT_EQ
(
std
::
string
(
"MyTestString"
),
cp
[
c_it
->
idx
()
]);
EXPECT_EQ
(
std
::
string
(
"MyTestString"
),
cp
[
*
c_it
]);
}
EXPECT_FALSE
(
mesh_
.
halfedge_property_exists
<
unsigned
char
>
(
"HEProp"
));
...
...
@@ -1658,7 +1658,7 @@ TEST_F(HexahedralMeshBase, GarbageCollectionTestProps1) {
std
::
set
<
int
>
fprops_i
;
for
(
FaceIter
f_it
=
mesh_
.
f_iter
();
f_it
.
valid
();
++
f_it
)
{
fprops_i
.
insert
(
fprop
[
f_it
->
idx
()
]);
fprops_i
.
insert
(
fprop
[
*
f_it
]);
}
EXPECT_EQ
(
0u
,
fprops_i
.
count
(
11
));
...
...
@@ -1717,7 +1717,7 @@ TEST_F(HexahedralMeshBase, GarbageCollectionTestProps2) {
std
::
set
<
int
>
fprops_i
;
for
(
FaceIter
f_it
=
mesh_
.
f_iter
();
f_it
.
valid
();
++
f_it
)
{
fprops_i
.
insert
(
fprop
[
f_it
->
idx
()
]);
fprops_i
.
insert
(
fprop
[
*
f_it
]);
}
EXPECT_EQ
(
0u
,
fprops_i
.
count
(
11
));
...
...
src/Unittests/unittests_files.cc
View file @
854c2dfd
...
...
@@ -84,10 +84,10 @@ TEST_F(PolyhedralMeshBase, SaveFileWithProps) {
VertexPropertyT
<
unsigned
int
>
vprop
=
mesh_
.
request_vertex_property
<
unsigned
int
>
(
"MyVertexProp"
);
for
(
unsigned
int
i
=
0
;
i
<
mesh_
.
n_halffaces
();
++
i
)
{
hfprop
[
i
]
=
(
float
)
i
/
2.0
f
;
hfprop
[
HalfFaceHandle
(
i
)
]
=
(
float
)
i
/
2.0
f
;
}
for
(
unsigned
int
i
=
0
;
i
<
mesh_
.
n_vertices
();
++
i
)
{
vprop
[
i
]
=
i
;
vprop
[
VertexHandle
(
i
)
]
=
i
;
}
mesh_
.
set_persistent
(
hfprop
);
...
...
@@ -112,10 +112,10 @@ TEST_F(PolyhedralMeshBase, SaveFileWithProps) {
VertexPropertyT
<
unsigned
int
>
vprop2
=
mesh_
.
request_vertex_property
<
unsigned
int
>
(
"MyVertexProp"
);
for
(
unsigned
int
i
=
0
;
i
<
mesh_
.
n_halffaces
();
++
i
)
{
EXPECT_FLOAT_EQ
((
float
)
i
/
2.0
f
,
hfprop2
[
i
]);
EXPECT_FLOAT_EQ
((
float
)
i
/
2.0
f
,
hfprop2
[
HalfFaceHandle
(
i
)
]);
}
for
(
unsigned
int
i
=
0
;
i
<
mesh_
.
n_vertices
();
++
i
)
{
EXPECT_EQ
(
i
,
vprop2
[
i
]);
EXPECT_EQ
(
i
,
vprop2
[
VertexHandle
(
i
)
]);
}
}
...
...
@@ -135,10 +135,10 @@ TEST_F(PolyhedralMeshBase, SaveFileWithVectorProps) {
VertexPropertyT
<
Vec2i
>
vprop
=
mesh_
.
request_vertex_property
<
Vec2i
>
(
"MyVertexProp"
);
for
(
unsigned
int
i
=
0
;
i
<
mesh_
.
n_halffaces
();
++
i
)
{
hfprop
[
i
]
=
Vec3d
((
double
)
i
/
2.0
,
(
double
)
i
/
2.0
,
(
double
)
i
/
2.0
);
hfprop
[
HalfFaceHandle
(
i
)
]
=
Vec3d
((
double
)
i
/
2.0
,
(
double
)
i
/
2.0
,
(
double
)
i
/
2.0
);
}
for
(
unsigned
int
i
=
0
;
i
<
mesh_
.
n_vertices
();
++
i
)
{
vprop
[
i
]
=
Vec2i
(
i
,
i
);
vprop
[
VertexHandle
(
i
)
]
=
Vec2i
(
i
,
i
);
}
mesh_
.
set_persistent
(
hfprop
);
...
...
@@ -163,13 +163,15 @@ TEST_F(PolyhedralMeshBase, SaveFileWithVectorProps) {
VertexPropertyT
<
Vec2i
>
vprop2
=
mesh_
.
request_vertex_property
<
Vec2i
>
(
"MyVertexProp"
);
for
(
unsigned
int
i
=
0
;
i
<
mesh_
.
n_halffaces
();
++
i
)
{
EXPECT_DOUBLE_EQ
((
double
)
i
/
2.0
,
hfprop2
[
i
][
0
]);
EXPECT_DOUBLE_EQ
((
double
)
i
/
2.0
,
hfprop2
[
i
][
1
]);
EXPECT_DOUBLE_EQ
((
double
)
i
/
2.0
,
hfprop2
[
i
][
2
]);
HalfFaceHandle
hfh
(
i
);
EXPECT_DOUBLE_EQ
((
double
)
i
/
2.0
,
hfprop2
[
hfh
][
0
]);
EXPECT_DOUBLE_EQ
((
double
)
i
/
2.0
,
hfprop2
[
hfh
][
1
]);
EXPECT_DOUBLE_EQ
((
double
)
i
/
2.0
,
hfprop2
[
hfh
][
2
]);
}
for
(
unsigned
int
i
=
0
;
i
<
mesh_
.
n_vertices
();
++
i
)
{
EXPECT_EQ
((
int
)
i
,
vprop2
[
i
][
0
]);
EXPECT_EQ
((
int
)
i
,
vprop2
[
i
][
1
]);
VertexHandle
vh
(
i
);
EXPECT_EQ
((
int
)
i
,
vprop2
[
vh
][
0
]);
EXPECT_EQ
((
int
)
i
,
vprop2
[
vh
][
1
]);
}
}
...
...
@@ -189,10 +191,12 @@ TEST_F(PolyhedralMeshBase, SerializeVectorValuedProperties) {
VertexPropertyT
<
Vec2i
>
vprop
=
mesh_
.
request_vertex_property
<
Vec2i
>
(
"MyVertexProp"
);
for
(
unsigned
int
i
=
0
;
i
<
mesh_
.
n_halffaces
();
++
i
)
{
hfprop
[
i
]
=
Vec3d
((
double
)
i
/
2.0
,
(
double
)
i
/
2.0
,
(
double
)
i
/
2.0
);
HalfFaceHandle
hfh
(
i
);
hfprop
[
hfh
]
=
Vec3d
((
double
)
i
/
2.0
,
(
double
)
i
/
2.0
,
(
double
)
i
/
2.0
);
}
for
(
unsigned
int
i
=
0
;
i
<
mesh_
.
n_vertices
();
++
i
)
{
vprop
[
i
]
=
Vec2i
(
i
,
i
);
VertexHandle
vh
(
i
);
vprop
[
vh
]
=
Vec2i
(
i
,
i
);
}
mesh_
.
set_persistent
(
hfprop
);
...
...
@@ -211,11 +215,11 @@ TEST_F(PolyhedralMeshBase, SerializeVectorValuedProperties) {
* Change property values
*/
for
(
unsigned
int
i
=
0
;
i
<
mesh_
.
n_halffaces
();
++
i
)
{
hfprop
[
i
]
=
Vec3d
((
double
)
i
/
3.0
,
(
double
)
i
/
3.0
,
(
double
)
i
/
3.0
);
hfprop
[
HalfFaceHandle
(
i
)
]
=
Vec3d
((
double
)
i
/
3.0
,
(
double
)
i
/
3.0
,
(
double
)
i
/
3.0
);
}
for
(
unsigned
int
i
=
0
;
i
<
mesh_
.
n_vertices
();
++
i
)
{
vprop
[
i
]
=
Vec2i
(
2
*
i
,
2
*
i
);
vprop
[
VertexHandle
(
i
)
]
=
Vec2i
(
2
*
i
,
2
*
i
);
}
std
::
ifstream
ifs1
(
"hfVecPropTest"
);
...
...
@@ -228,13 +232,15 @@ TEST_F(PolyhedralMeshBase, SerializeVectorValuedProperties) {
ifs2
.
close
();
for
(
unsigned
int
i
=
0
;
i
<
mesh_
.
n_halffaces
();
++
i
)
{
EXPECT_DOUBLE_EQ
((
double
)
i
/
2.0
,
hfprop
[
i
][
0
]);
EXPECT_DOUBLE_EQ
((
double
)
i
/
2.0
,
hfprop
[
i
][
1
]);
EXPECT_DOUBLE_EQ
((
double
)
i
/
2.0
,
hfprop
[
i
][
2
]);
HalfFaceHandle
hfh
(
i
);
EXPECT_DOUBLE_EQ
((
double
)
i
/
2.0
,
hfprop
[
hfh
][
0
]);
EXPECT_DOUBLE_EQ
((
double
)
i
/
2.0
,
hfprop
[
hfh
][
1
]);
EXPECT_DOUBLE_EQ
((
double
)
i
/
2.0
,
hfprop
[
hfh
][
2
]);
}
for
(
unsigned
int
i
=
0
;
i
<
mesh_
.
n_vertices
();
++
i
)
{
EXPECT_EQ
((
int
)
i
,
vprop
[
i
][
0
]);
EXPECT_EQ
((
int
)
i
,
vprop
[
i
][
1
]);
VertexHandle
vh
(
i
);
EXPECT_EQ
((
int
)
i
,
vprop
[
vh
][
0
]);
EXPECT_EQ
((
int
)
i
,
vprop
[
vh
][
1
]);
}
}
...
...
src/Unittests/unittests_properties.cc
View file @
854c2dfd
...
...
@@ -32,7 +32,7 @@ TEST_F(PolyhedralMeshBase, PropertySmartPointerTest1) {
VertexPropertyT
<
float
>
v_prop
=
mesh_
.
request_vertex_property
<
float
>
(
"MyVProp"
);
v_prop
[
0
]
=
1.4
f
;
v_prop
[
VertexHandle
(
0
)
]
=
1.4
f
;
VertexPropertyT
<
float
>
v_prop2
(
v_prop
);
...
...
@@ -46,7 +46,7 @@ TEST_F(PolyhedralMeshBase, PropertySmartPointerTest1) {
EXPECT_EQ
(
2u
,
mesh_
.
n_vertex_props
());
EXPECT_FLOAT_EQ
(
1.4
f
,
v_prop3
[
0
]);
EXPECT_FLOAT_EQ
(
1.4
f
,
v_prop3
[
VertexHandle
(
0
)
]);
VertexPropertyT
<
std
::
string
>
v_prop_duplicate_2
=
mesh_
.
request_vertex_property
<
std
::
string
>
(
"MyVProp"
);
...
...
@@ -82,16 +82,16 @@ TEST_F(HexahedralMeshBase, PropertySmartPointerPersistencyTest1) {
VertexPropertyT
<
float
>
v_prop
=
mesh_
.
request_vertex_property
<
float
>
(
"FloatVProp"
);
v_prop
[
0
]
=
24.5
f
;
v_prop
[
11
]
=
2.34
f
;
v_prop
[
VertexHandle
(
0
)
]
=
24.5
f
;
v_prop
[
VertexHandle
(
11
)
]
=
2.34
f
;
mesh_
.
set_persistent
(
v_prop
);
}
VertexPropertyT
<
float
>
v_prop2
=
mesh_
.
request_vertex_property
<
float
>
(
"FloatVProp"
);
EXPECT_FLOAT_EQ
(
24.5
f
,
v_prop2
[
0
]);
EXPECT_FLOAT_EQ
(
2.34
f
,
v_prop2
[
11
]);
EXPECT_FLOAT_EQ
(
24.5
f
,
v_prop2
[
VertexHandle
(
0
)
]);
EXPECT_FLOAT_EQ
(
2.34
f
,
v_prop2
[
VertexHandle
(
11
)
]);
}
TEST_F
(
HexahedralMeshBase
,
PropertySmartPointerPersistencyTest2
)
{
...
...
@@ -165,8 +165,8 @@ TEST_F(PolyhedralMeshBase, PropValueCopyTest) {
generatePolyhedralMesh
(
mesh_
);
VertexPropertyT
<
int
>
prop
=
mesh_
.
request_vertex_property
<
int
>
();
prop
[
0
]
=
1234
;
prop
[
1
]
=
2345
;
prop
[
VertexHandle
(
0
)
]
=
1234
;
prop
[
VertexHandle
(
1
)
]
=
2345
;
prop
.
copy
(
0
,
1
);
EXPECT_EQ
(
prop
[
1
],
1234
);
EXPECT_EQ
(
prop
[
VertexHandle
(
1
)
],
1234
);
}
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment