Skip to content

Commit

Permalink
Remove code duplication uncovered by -Wshadow
Browse files Browse the repository at this point in the history
  • Loading branch information
dsieger committed Dec 31, 2021
1 parent 4e6a2d1 commit 6253345
Showing 1 changed file with 15 additions and 34 deletions.
49 changes: 15 additions & 34 deletions tests/SurfaceMeshTest.cpp
Expand Up @@ -17,19 +17,16 @@ TEST_F(SurfaceMeshTest, emptyMesh)

TEST_F(SurfaceMeshTest, insert_remove_single_vertex)
{
auto v0 = mesh.add_vertex(Point(0, 0, 0));
auto v = mesh.add_vertex(Point(0, 0, 0));
EXPECT_EQ(mesh.n_vertices(), size_t(1));
mesh.delete_vertex(v0);
mesh.delete_vertex(v);
mesh.garbage_collection();
EXPECT_EQ(mesh.n_vertices(), size_t(0));
}

TEST_F(SurfaceMeshTest, insert_remove_single_triangle)
{
auto v0 = mesh.add_vertex(Point(0, 0, 0));
auto v1 = mesh.add_vertex(Point(1, 0, 0));
auto v2 = mesh.add_vertex(Point(0, 1, 0));
auto f0 = mesh.add_triangle(v0, v1, v2);
add_triangle();
EXPECT_EQ(mesh.n_vertices(), size_t(3));
EXPECT_EQ(mesh.n_edges(), size_t(3));
EXPECT_EQ(mesh.n_faces(), size_t(1));
Expand All @@ -42,11 +39,7 @@ TEST_F(SurfaceMeshTest, insert_remove_single_triangle)

TEST_F(SurfaceMeshTest, insert_remove_single_quad)
{
auto v0 = mesh.add_vertex(Point(0, 0, 0));
auto v1 = mesh.add_vertex(Point(1, 0, 0));
auto v2 = mesh.add_vertex(Point(1, 1, 0));
auto v3 = mesh.add_vertex(Point(0, 1, 0));
auto f0 = mesh.add_quad(v0, v1, v2, v3);
add_quad();
EXPECT_EQ(mesh.n_vertices(), size_t(4));
EXPECT_EQ(mesh.n_edges(), size_t(4));
EXPECT_EQ(mesh.n_faces(), size_t(1));
Expand All @@ -65,11 +58,11 @@ TEST_F(SurfaceMeshTest, insert_remove_single_polygonal_face)
vertices[2] = mesh.add_vertex(Point(1, 1, 0));
vertices[3] = mesh.add_vertex(Point(0, 1, 0));

auto f0 = mesh.add_face(vertices);
auto f = mesh.add_face(vertices);
EXPECT_EQ(mesh.n_vertices(), size_t(4));
EXPECT_EQ(mesh.n_edges(), size_t(4));
EXPECT_EQ(mesh.n_faces(), size_t(1));
mesh.delete_face(f0);
mesh.delete_face(f);
mesh.garbage_collection();
EXPECT_EQ(mesh.n_vertices(), size_t(0));
EXPECT_EQ(mesh.n_edges(), size_t(0));
Expand All @@ -81,8 +74,8 @@ TEST_F(SurfaceMeshTest, delete_center_vertex)
mesh = vertex_onering();
EXPECT_EQ(mesh.n_vertices(), size_t(7));
EXPECT_EQ(mesh.n_faces(), size_t(6));
Vertex v0(3); // the central vertex
mesh.delete_vertex(v0);
Vertex v(3); // the central vertex
mesh.delete_vertex(v);
mesh.garbage_collection();
EXPECT_EQ(mesh.n_vertices(), size_t(0));
EXPECT_EQ(mesh.n_faces(), size_t(0));
Expand All @@ -94,8 +87,8 @@ TEST_F(SurfaceMeshTest, delete_center_edge)
EXPECT_EQ(mesh.n_vertices(), size_t(10));
EXPECT_EQ(mesh.n_faces(), size_t(10));
// the two vertices of the center edge
Vertex v0(4);
Vertex v1(5);
v0 = Vertex(4);
v1 = Vertex(5);

auto e = mesh.find_edge(v0, v1);
mesh.delete_edge(e);
Expand All @@ -106,11 +99,7 @@ TEST_F(SurfaceMeshTest, delete_center_edge)

TEST_F(SurfaceMeshTest, copy)
{
auto v0 = mesh.add_vertex(Point(0, 0, 0));
auto v1 = mesh.add_vertex(Point(1, 0, 0));
auto v2 = mesh.add_vertex(Point(0, 1, 0));
mesh.add_triangle(v0, v1, v2);

add_triangle();
SurfaceMesh m2 = mesh;
EXPECT_EQ(m2.n_vertices(), size_t(3));
EXPECT_EQ(m2.n_edges(), size_t(3));
Expand All @@ -119,11 +108,7 @@ TEST_F(SurfaceMeshTest, copy)

TEST_F(SurfaceMeshTest, assignment)
{
auto v0 = mesh.add_vertex(Point(0, 0, 0));
auto v1 = mesh.add_vertex(Point(1, 0, 0));
auto v2 = mesh.add_vertex(Point(0, 1, 0));
mesh.add_triangle(v0, v1, v2);

add_triangle();
SurfaceMesh m2;
m2.assign(mesh);
EXPECT_EQ(m2.n_vertices(), size_t(3));
Expand Down Expand Up @@ -272,11 +257,7 @@ TEST_F(SurfaceMeshTest, is_triangle_mesh)

TEST_F(SurfaceMeshTest, is_quad_mesh)
{
auto v0 = mesh.add_vertex(Point(0, 0, 0));
auto v1 = mesh.add_vertex(Point(1, 0, 0));
auto v2 = mesh.add_vertex(Point(1, 1, 0));
auto v3 = mesh.add_vertex(Point(0, 1, 0));
mesh.add_quad(v0, v1, v2, v3);
add_quad();
EXPECT_TRUE(mesh.is_quad_mesh());
}

Expand Down Expand Up @@ -367,8 +348,8 @@ TEST_F(SurfaceMeshTest, edge_flip)
EXPECT_EQ(mesh.n_faces(), size_t(10));

// the two vertices of the center edge
Vertex v0(4);
Vertex v1(5);
v0 = Vertex(4);
v1 = Vertex(5);
auto e = mesh.find_edge(v0, v1);
if (mesh.is_flip_ok(e))
mesh.flip(e);
Expand Down

0 comments on commit 6253345

Please sign in to comment.