From 7e550c7e26dad7e408b1bf02b60e8b89c8d1e09d Mon Sep 17 00:00:00 2001 From: bgbsww Date: Wed, 24 Jan 2024 20:10:55 -0500 Subject: [PATCH] Rename test and add more assertions --- .../App/TopoShapeMakeShapeWithElementMap.cpp | 44 ++++++++++++------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/tests/src/Mod/Part/App/TopoShapeMakeShapeWithElementMap.cpp b/tests/src/Mod/Part/App/TopoShapeMakeShapeWithElementMap.cpp index 584652d5c5..cc1bcf0916 100644 --- a/tests/src/Mod/Part/App/TopoShapeMakeShapeWithElementMap.cpp +++ b/tests/src/Mod/Part/App/TopoShapeMakeShapeWithElementMap.cpp @@ -63,16 +63,15 @@ TEST_F(TopoShapeMakeShapeWithElementMapTests, nullShapeThrows) using Data::IndexedName, Data::MappedName; using Part::TopoShape; + // TEST_F(TopoShapeMakeShapeWithElementMapTests, mapVertex) // TEST_F(TopoShapeMakeShapeWithElementMapTests, mapEdge) // TEST_F(TopoShapeMakeShapeWithElementMapTests, mapWire) // TEST_F(TopoShapeMakeShapeWithElementMapTests, mapFace) // TEST_F(TopoShapeMakeShapeWithElementMapTests, mapShell) // TEST_F(TopoShapeMakeShapeWithElementMapTests, mapSolid) -// TEST_F(TopoShapeMakeShapeWithElementMapTests, mapCompound) -// TEST_F(TopoShapeMakeShapeWithElementMapTests, mapCompSolid) -// TEST_F(TopoShapeMakeShapeWithElementMapTests, mapOffsetCubes) -TEST_F(TopoShapeMakeShapeWithElementMapTests, mapIntersectingCubes) + +TEST_F(TopoShapeMakeShapeWithElementMapTests, mapCompound) { // Arrange auto [cube1, cube2] = TopoShapeExpansionHelpers::CreateTwoCubes(); @@ -82,25 +81,40 @@ TEST_F(TopoShapeMakeShapeWithElementMapTests, mapIntersectingCubes) std::vector sources {cube1, cube2}; sources[0].Tag = 1; sources[1].Tag = 2; - // sources[0].makeShapeWithElementMap(sources[0].getShape(), *Mapper(), {sources[0]}); - // sources[1].makeShapeWithElementMap(sources[1].getShape(), *Mapper(), {sources[1]}); - + // Map only one of the two sources to test different names. + sources[0].makeShapeWithElementMap(sources[0].getShape(), *Mapper(), {sources[0]}); TopoShape compound; compound.makeElementCompound(sources); + auto preElements = compound.getElementMap(); // Map before mapping. + std::map preMap; + for (auto name : preElements) { + preMap.emplace(name.index, name.name); + } // Act compound.makeShapeWithElementMap(compound.getShape(), *Mapper(), sources); - auto elements = compound.getElementMap(); - std::map mapped; + auto elements = compound.getElementMap(); // Map after mapping + std::map map; for (auto name : elements) { - mapped.emplace(name.index, name.name); + map.emplace(name.index, name.name); } // Assert - EXPECT_EQ(elements.size(), 52); - EXPECT_EQ(mapped[IndexedName("Edge1")], MappedName("Edge1;MAK;:H1:4,E")); - EXPECT_EQ(mapped[IndexedName("Edge", 13)], MappedName("Edge1;MAK;:H2:4,E")); - // EXPECT_STREQ(mapped[IndexedName("Edge1")],MappedName("Edge1;MAK;:H:4,E;MAK;:H1:f,E")); - // EXPECT_STREQ(mapped[IndexedName("Edge",13)],MappedName("Edge1;MAK;:H:4,E;MAK;:H2:f,E")); + EXPECT_EQ(preElements.size(), 52); // Check the before map. + EXPECT_EQ(preMap[IndexedName("Edge", 1)], MappedName("Edge1;MAK;:H:4,E;:H1:b,E")); + EXPECT_EQ(preMap[IndexedName("Edge", 13)], MappedName("Edge1;:H2,E")); + + EXPECT_EQ(elements.size(), 52); // 12 Edges, 8 Vertexes, 6 Faces per each Cube + EXPECT_EQ(map[IndexedName("Edge", 1)], MappedName("Edge1;MAK;:H:4,E;MAK;:H1:f,E")); + EXPECT_EQ(map[IndexedName("Edge", 13)], MappedName("Edge1;MAK;:H2:4,E")); + EXPECT_EQ(map.count(IndexedName("Edge", 24)), 1); + EXPECT_EQ(map.count(IndexedName("Edge", 25)), 0); + EXPECT_EQ(map.count(IndexedName("Vertex", 16)), 1); + EXPECT_EQ(map.count(IndexedName("Vertex", 17)), 0); + EXPECT_EQ(map.count(IndexedName("Face", 12)), 1); + EXPECT_EQ(map.count(IndexedName("Face", 13)), 0); EXPECT_STREQ(sources[0].shapeName().c_str(), "Solid"); EXPECT_STREQ(sources[1].shapeName().c_str(), "Solid"); EXPECT_STREQ(compound.shapeName().c_str(), "Compound"); } +// TEST_F(TopoShapeMakeShapeWithElementMapTests, mapCompSolid) +// TEST_F(TopoShapeMakeShapeWithElementMapTests, mapOffsetCubes) +// TEST_F(TopoShapeMakeShapeWithElementMapTests, mapIntersectingCubes)