diff --git a/tests/src/Mod/Part/App/WireJoiner.cpp b/tests/src/Mod/Part/App/WireJoiner.cpp index 0020178d22..717b8a4b3c 100644 --- a/tests/src/Mod/Part/App/WireJoiner.cpp +++ b/tests/src/Mod/Part/App/WireJoiner.cpp @@ -822,7 +822,7 @@ TEST_F(WireJoinerTest, Modified) // A vector of edges used as argument for wjModified.addShape() std::vector edges {edge1, edge2, edge3}; - // A WireJoiner object that will create no closed wires + // A WireJoiner object that will have shapes modified by the added edges auto wjModified {WireJoiner()}; // Act @@ -866,7 +866,7 @@ TEST_F(WireJoinerTest, Generated) // A vector of edges used as argument for wjGenerated.addShape() std::vector edges {edge1, edge2, edge3}; - // A WireJoiner object that will create no closed wires + // A WireJoiner object that will have shapes generated by the added edges auto wjGenerated {WireJoiner()}; // Act @@ -889,4 +889,43 @@ TEST_F(WireJoinerTest, Generated) EXPECT_EQ(wjGenerated.Generated(edge3).Size(), 0); } +TEST_F(WireJoinerTest, IsDeleted) +{ + + // Create various edges that will be used for the WireJoiner objects tests + + auto edge1 {BRepBuilderAPI_MakeEdge(gp_Pnt(0.0, 0.0, 0.0), gp_Pnt(1.0, 0.0, 0.0)).Edge()}; + auto edge2 {BRepBuilderAPI_MakeEdge(gp_Pnt(1.0, 0.0, 0.0), gp_Pnt(1.0, 1.0, 0.0)).Edge()}; + auto edge3 {BRepBuilderAPI_MakeEdge(gp_Pnt(1.0, 1.0, 0.0), gp_Pnt(0.0, 0.0, 0.0)).Edge()}; + auto edge4 {BRepBuilderAPI_MakeEdge(gp_Pnt(1.0, 1.0, 0.0), gp_Pnt(0.0, 0.0, 0.0)).Edge()}; + auto edge5 {BRepBuilderAPI_MakeEdge(gp_Pnt(0.49, 0.0, 0.0), gp_Pnt(0.51, 0.0, 0.0)).Edge()}; + + // A vector of edges used as argument for wjIsDeleted.addShape() + std::vector edges {edge1, edge2, edge3, edge4, edge5}; + + // A WireJoiner object that will have shapes deleted by the added edges + auto wjIsDeleted {WireJoiner()}; + // To get all the deleted shapes in this case we also need to set the tolerance value + wjIsDeleted.setTolerance(0.03); + + // Act + + wjIsDeleted.addShape(edges); + wjIsDeleted.Build(); + + // Assert + + // In this case, edge1, edge2 and edge3 don't meet the conditions for deletion + EXPECT_FALSE(wjIsDeleted.IsDeleted(edge1)); + EXPECT_FALSE(wjIsDeleted.IsDeleted(edge2)); + EXPECT_FALSE(wjIsDeleted.IsDeleted(edge3)); + + // edge4 is a duplicate of edge3 and therefor deleted + EXPECT_TRUE(wjIsDeleted.IsDeleted(edge4)); + + // edge5 is smaller that the smallest shape that can be considered with the given value of + // tolerance and therefor deleted + EXPECT_TRUE(wjIsDeleted.IsDeleted(edge5)); +} + // NOLINTEND(readability-magic-numbers,cppcoreguidelines-avoid-magic-numbers)