From a2d15df6df0605b38e25c05aca5ea3c0ea4b1f1d Mon Sep 17 00:00:00 2001 From: bgbsww Date: Thu, 18 Jan 2024 13:15:21 -0500 Subject: [PATCH] Split test cases --- tests/src/Mod/Part/App/TopoShapeExpansion.cpp | 67 ++++++++++++++----- 1 file changed, 51 insertions(+), 16 deletions(-) diff --git a/tests/src/Mod/Part/App/TopoShapeExpansion.cpp b/tests/src/Mod/Part/App/TopoShapeExpansion.cpp index 360898d323..3d71be8070 100644 --- a/tests/src/Mod/Part/App/TopoShapeExpansion.cpp +++ b/tests/src/Mod/Part/App/TopoShapeExpansion.cpp @@ -162,23 +162,19 @@ TEST_F(TopoShapeExpansionTest, makeElementCompoundTwoCubes) } -TEST_F(TopoShapeExpansionTest, mapSubElement) +TEST_F(TopoShapeExpansionTest, mapSubElementOneCube) { // Arrange auto [cube1, cube2] = CreateTwoCubes(); - Part::TopoShape cube1TS {cube1}; - cube1TS.Tag = 1; - Part::TopoShape cube2TS {cube2}; - cube2TS.Tag = 2; auto [cube3, cube4] = CreateTwoCubes(); - Part::TopoShape cube3TS {cube3}; - cube3TS.Tag = 3; - Part::TopoShape cube4TS {cube4}; - cube4TS.Tag = 4; + Part::TopoShape cube1TS {cube1}; + Part::TopoShape cube2TS {cube2}; + cube1TS.Tag = 1; + cube2TS.Tag = 2; std::vector subShapes = cube1TS.getSubTopoShapes(TopAbs_FACE); Part::TopoShape face1 = subShapes.front(); - face1.Tag = 3; - Part::TopoShape topoShape, topoShape1; + face1.Tag = 5; + Part::TopoShape topoShape; // Act int fs1 = topoShape.findShape(cube1TS.getShape()); @@ -187,12 +183,11 @@ TEST_F(TopoShapeExpansionTest, mapSubElement) // The cache ancestry only works on TopAbs_SHAPE so this is likely an invalid call, // but do we defend against it or expect the exception? - topoShape.mapSubElement( - cube1TS); // Once we do this map, it's in the ancestry cache forevermore + topoShape.mapSubElement(cube1TS); int fs2 = topoShape.findShape(cube1TS.getShape()); int fs3 = topoShape.findShape(face1.getShape()); - int size1 = topoShape.getElementMap().size(); int size0 = cube1TS.getElementMap().size(); + int size1 = topoShape.getElementMap().size(); // Assert EXPECT_EQ(fs1, 0); @@ -200,19 +195,58 @@ TEST_F(TopoShapeExpansionTest, mapSubElement) EXPECT_EQ(fs3, 1); EXPECT_EQ(0, size0); EXPECT_EQ(26, size1); +} + +TEST_F(TopoShapeExpansionTest, mapSubElementSetReset) +{ + // Arrange + auto [cube1, cube2] = CreateTwoCubes(); + auto [cube3, cube4] = CreateTwoCubes(); + Part::TopoShape cube1TS {cube1}; + Part::TopoShape cube2TS {cube2}; + Part::TopoShape cube3TS {cube3}; + Part::TopoShape cube4TS {cube4}; + cube1TS.Tag = 1; + cube2TS.Tag = 2; + cube3TS.Tag = 3; + cube4TS.Tag = 4; + std::vector subShapes = cube1TS.getSubTopoShapes(TopAbs_FACE); + Part::TopoShape face1 = subShapes.front(); + face1.Tag = 5; + Part::TopoShape topoShape, topoShape1; // Act topoShape.setShape(TopoDS_Shape()); int fs4 = topoShape.findShape(cube1TS.getShape()); - topoShape.setShape(cube1, true); + topoShape.setShape(cube1, false); + // topoShape.mapSubElement(cube1TS); // No mapSubElement required, it keeps finding it now int fs5 = topoShape.findShape(cube1TS.getShape()); - topoShape.setShape(cube1, false); + topoShape.setShape(cube1, true); int fs6 = topoShape.findShape(cube1TS.getShape()); // Assert EXPECT_EQ(fs4, 0); EXPECT_EQ(fs5, 1); EXPECT_EQ(fs6, 1); +} + +TEST_F(TopoShapeExpansionTest, mapSubElementCompoundCubes) +{ + // Arrange + auto [cube1, cube2] = CreateTwoCubes(); + auto [cube3, cube4] = CreateTwoCubes(); + Part::TopoShape cube1TS {cube1}; + Part::TopoShape cube2TS {cube2}; + Part::TopoShape cube3TS {cube3}; + Part::TopoShape cube4TS {cube4}; + cube1TS.Tag = 1; + cube2TS.Tag = 2; + cube3TS.Tag = 3; + cube4TS.Tag = 4; + std::vector subShapes = cube1TS.getSubTopoShapes(TopAbs_FACE); + Part::TopoShape face1 = subShapes.front(); + face1.Tag = 5; + Part::TopoShape topoShape, topoShape1; // Act Part::TopoShape topoShape2, topoShape3; @@ -248,4 +282,5 @@ TEST_F(TopoShapeExpansionTest, mapSubElement) EXPECT_EQ(fs12, 4); } + // NOLINTEND(readability-magic-numbers,cppcoreguidelines-avoid-magic-numbers)