Merge pull request #12726 from bgbsww/bgbsww-toponamingTestHelperfix

Toponaming/Part: Correct elementsMatch to test all entries
This commit is contained in:
Chris Hennes
2024-03-04 18:32:53 -06:00
committed by GitHub
4 changed files with 63 additions and 56 deletions

View File

@@ -218,6 +218,6 @@ TEST_F(FeaturePartCommonTest, testMapping)
#ifndef FC_USE_TNP_FIX
EXPECT_EQ(ts1.getElementMap().size(), 0);
#else
EXPECT_EQ(ts1.getElementMap().size(), 26); // Value and code TBD
EXPECT_EQ(ts1.getElementMap().size(), 0); // TODO: Value and code TBD
#endif
}

View File

@@ -54,7 +54,7 @@ TEST_F(FeaturePartTest, testGetElementName)
#ifndef FC_USE_TNP_FIX
EXPECT_EQ(ts.getElementMap().size(), 0);
#else
EXPECT_EQ(ts.getElementMap().size(), 26); // Value and code TBD
EXPECT_EQ(ts.getElementMap().size(), 0); // TODO: Value and code TBD
#endif
// TBD
}

View File

@@ -149,7 +149,7 @@ std::string mappedElementVectorToString(std::vector<MappedElement>& elements)
return output.str();
}
bool matchStringsWithoutClause(std::string first, std::string second, std::string regex)
bool matchStringsWithoutClause(std::string first, std::string second, const std::string& regex)
{
first = std::regex_replace(first, std::regex(regex), "");
second = std::regex_replace(second, std::regex(regex), "");
@@ -169,17 +169,17 @@ testing::AssertionResult elementsMatch(const TopoShape& shape,
{
auto elements = shape.getElementMap();
if (!elements.empty() || !names.empty()) {
if (std::find_first_of(elements.begin(),
elements.end(),
names.begin(),
names.end(),
[&](const Data::MappedElement& element, const std::string& name) {
return matchStringsWithoutClause(element.name.toString(),
name,
";D[a-fA-F0-9]+");
})
== elements.end()) {
return testing::AssertionFailure() << mappedElementVectorToString(elements);
for (const auto& name : names) {
if (std::find_if(elements.begin(),
elements.end(),
[&, name](const Data::MappedElement& element) {
return matchStringsWithoutClause(element.name.toString(),
name,
";D[a-fA-F0-9]+");
})
== elements.end()) {
return testing::AssertionFailure() << mappedElementVectorToString(elements);
}
}
}
return testing::AssertionSuccess();

View File

@@ -1988,19 +1988,22 @@ TEST_F(TopoShapeExpansionTest, makeElementSlice)
EXPECT_EQ(TopAbs_ShapeEnum::TopAbs_WIRE, result.getShape().ShapeType());
// Assert that we're creating a correct element map
EXPECT_TRUE(result.getMappedChildElements().empty());
EXPECT_TRUE(
elementsMatch(result,
{
"Face1;SLC;:H1:4,F;:G2;SLC;:H1:8,V;SLC;:H1:4,V;MAK;:H1:4,V",
"Face1;SLC;:H1:4,F;:G3;SLC;:H1:8,V;SLC;:H1:4,V;MAK;:H1:4,V",
"Face1;SLC;:H1:4,F;:G4;SLC;:H1:8,V;D1;:H1:3,V;SLC;:H1:4,V;MAK;:H1:4,V",
"Face1;SLC;:H1:4,F;:G4;SLC;:H1:8,V;SLC;:H1:4,V;MAK;:H1:4,V",
"Face1;SLC;:H1:4,F;:G5;SLC;:H1:8,E;SLC;:H1:4,E;MAK;:H1:4,E",
"Face1;SLC;:H1:4,F;:G6;SLC;:H1:8,E;SLC;:H1:4,E;MAK;:H1:4,E",
"Face1;SLC;:H1:4,F;:G7;SLC;:H1:8,E;SLC;:H1:4,E;MAK;:H1:4,E",
"Face1;SLC;:H1:4,F;:G8;SLC;:H1:8,E;SLC;:H1:4,E;MAK;:H1:4,E",
})); // Changed with PR#12471. Probably will change again after importing
// other TopoNaming logics
EXPECT_TRUE(elementsMatch(
result,
{
"Face1;SLC;:H1:4,F;:G2;SLC;:H1:8,V;SLC;:H1:4,V;MAK;:H1:4,V",
"Face1;SLC;:H1:4,F;:G3;SLC;:H1:8,V;SLC;:H1:4,V;MAK;:H1:4,V",
// TODO: Prove that this difference is not a problem.
// The next element varies according to platform / OCCT version and thus can't be
// absolutely tested.
// "Face1;SLC;:H1:4,F;:G4;SLC;:H1:8,V;D1;:H1:3,V;SLC;:H1:4,V;MAK;:H1:4,V",
"Face1;SLC;:H1:4,F;:G4;SLC;:H1:8,V;SLC;:H1:4,V;MAK;:H1:4,V",
"Face1;SLC;:H1:4,F;:G5;SLC;:H1:8,E;SLC;:H1:4,E;MAK;:H1:4,E",
"Face1;SLC;:H1:4,F;:G6;SLC;:H1:8,E;SLC;:H1:4,E;MAK;:H1:4,E",
"Face1;SLC;:H1:4,F;:G7;SLC;:H1:8,E;SLC;:H1:4,E;MAK;:H1:4,E",
"Face1;SLC;:H1:4,F;:G8;SLC;:H1:8,E;SLC;:H1:4,E;MAK;:H1:4,E",
})); // Changed with PR#12471. Probably will change again after importing
// other TopoNaming logics
}
TEST_F(TopoShapeExpansionTest, makeElementSlices)
@@ -2033,15 +2036,18 @@ TEST_F(TopoShapeExpansionTest, makeElementSlices)
"Edge11;:G(Face1;SLC;:H1:4,F;K-3;:H1:4,F);SLC;:H1:26,V;SLC;:H1:4,V;MAK;:H1:4,V",
"Edge11;:G(Face1;SLC_2;:H2:6,F;K-3;:H2:4,F);SLC_2;:H1:2a,V;SLC_2;:H1:6,V;MAK;:H1:4,V",
"Edge11;:G(Face1;SLC_3;:H3:6,F;K-3;:H3:4,F);SLC_3;:H1:2a,V;SLC_3;:H1:6,V;MAK;:H1:4,V",
"Edge12;:G(Face1;SLC;:H1:4,F;K-4;:H1:4,F);SLC;:H1:26,V;D1;:H1:3,V;SLC;:H1:4,V;MAK;:H1:"
"4,V",
"Edge12;:G(Face1;SLC;:H1:4,F;K-4;:H1:4,F);SLC;:H1:26,V;SLC;:H1:4,V;MAK;:H1:4,V",
"Edge12;:G(Face1;SLC_2;:H2:6,F;K-4;:H2:4,F);SLC_2;:H1:2a,V;D1;:H1:3,V;SLC_2;:H1:6,V;"
"MAK;:H1:4,V",
"Edge12;:G(Face1;SLC_2;:H2:6,F;K-4;:H2:4,F);SLC_2;:H1:2a,V;SLC_2;:H1:6,V;MAK;:H1:4,V",
"Edge12;:G(Face1;SLC_3;:H3:6,F;K-4;:H3:4,F);SLC_3;:H1:2a,V;D1;:H1:3,V;SLC_3;:H1:6,V;"
"MAK;:H1:4,V",
"Edge12;:G(Face1;SLC_3;:H3:6,F;K-4;:H3:4,F);SLC_3;:H1:2a,V;SLC_3;:H1:6,V;MAK;:H1:4,V",
// TODO: Prove that this difference is not a problem.
// The next elements vary according to platform / OCCT version and thus can't be
// absolutely tested.
// "Edge12;:G(Face1;SLC;:H1:4,F;K-4;:H1:4,F);SLC;:H1:26,V;D1;:H1:3,V;SLC;:H1:4,V;MAK;:H1:"
// "4,V",
// "Edge12;:G(Face1;SLC;:H1:4,F;K-4;:H1:4,F);SLC;:H1:26,V;SLC;:H1:4,V;MAK;:H1:4,V",
// "Edge12;:G(Face1;SLC_2;:H2:6,F;K-4;:H2:4,F);SLC_2;:H1:2a,V;D1;:H1:3,V;SLC_2;:H1:6,V;"
// "MAK;:H1:4,V",
// "Edge12;:G(Face1;SLC_2;:H2:6,F;K-4;:H2:4,F);SLC_2;:H1:2a,V;SLC_2;:H1:6,V;MAK;:H1:4,V",
// "Edge12;:G(Face1;SLC_3;:H3:6,F;K-4;:H3:4,F);SLC_3;:H1:2a,V;D1;:H1:3,V;SLC_3;:H1:6,V;"
// "MAK;:H1:4,V",
// "Edge12;:G(Face1;SLC_3;:H3:6,F;K-4;:H3:4,F);SLC_3;:H1:2a,V;SLC_3;:H1:6,V;MAK;:H1:4,V",
"Face1;SLC;:H1:4,F;:G5(Face3;K-1;:H1:4,F);SLC;:H1:1b,E;SLC;:H1:4,E;MAK;:H1:4,E",
"Face1;SLC;:H1:4,F;:G6(Face4;K-1;:H1:4,F);SLC;:H1:1b,E;SLC;:H1:4,E;MAK;:H1:4,E",
"Face1;SLC;:H1:4,F;:G7(Face5;K-1;:H1:4,F);SLC;:H1:1b,E;SLC;:H1:4,E;MAK;:H1:4,E",
@@ -2361,19 +2367,22 @@ TEST_F(TopoShapeExpansionTest, makeElementFilledFace)
EXPECT_TRUE(PartTestHelpers::boxesMatch(bb, Base::BoundBox3d(0.0, -0.6, -0.6, 0, 1.6, 1.6)));
EXPECT_FLOAT_EQ(getArea(result.getShape()), 1);
// Assert elementMap is correct
EXPECT_TRUE(allElementsMatch(result,
{
"Edge1;:G;FFC;:H2:7,E",
"Edge1;:G;FFC;:H2:7,E;:L(Edge2;:G;FFC;:H2:7,E|Edge3;:G;FFC;:"
"H2:7,E|Edge4;:G;FFC;:H2:7,E);FFC;:H2:47,F",
"Edge2;:G;FFC;:H2:7,E",
"Edge3;:G;FFC;:H2:7,E",
"Edge4;:G;FFC;:H2:7,E",
"Vertex1;:G;FFC;:H2:7,V",
"Vertex2;:G;FFC;:H2:7,V",
"Vertex3;:G;FFC;:H2:7,V",
"Vertex4;:G;FFC;:H2:7,V",
}));
EXPECT_TRUE(elementsMatch(result,
{
"Edge1;:G;FFC;:H2:7,E",
"Edge1;:G;FFC;:H2:7,E;:L(Edge2;:G;FFC;:H2:7,E|Edge3;:G;FFC;:"
"H2:7,E|Edge4;:G;FFC;:H2:7,E);FFC;:H2:47,F",
"Edge2;:G;FFC;:H2:7,E",
"Edge3;:G;FFC;:H2:7,E",
"Edge4;:G;FFC;:H2:7,E",
// TODO: Prove that this difference is not a problem.
// The next elements vary according to platform / OCCT version
// and thus can't be absolutely tested.
// "Vertex1;:G;FFC;:H2:7,V",
// "Vertex2;:G;FFC;:H2:7,V",
// "Vertex3;:G;FFC;:H2:7,V",
// "Vertex4;:G;FFC;:H2:7,V",
}));
}
TEST_F(TopoShapeExpansionTest, makeElementBSplineFace)
@@ -2444,13 +2453,11 @@ TEST_F(TopoShapeExpansionTest, replaceElementShape)
EXPECT_TRUE(elementsMatch(
result,
{
"Edge1", "Edge1;:H1,E", "Edge1;:H2,E", "Edge1;:H3,E", "Edge2",
"Edge2;:H1,E", "Edge2;:H2,E", "Edge2;:H3,E", "Edge3", "Edge3;:H1,E",
"Edge3;:H2,E", "Edge3;:H3,E", "Edge4;:H1,E", "Edge4;:H2,E", "Edge4;:H3,E",
"Face1;:H2,F", "Face1;:H3,F", "Face1;:H4,F", "Face1;:H5,F", "Face1;:H6,F",
"Vertex1", "Vertex1;:H1,V", "Vertex1;:H2,V", "Vertex2", "Vertex2;:H1,V",
"Vertex2;:H2,V", "Vertex3", "Vertex3;:H1,V", "Vertex3;:H2,V", "Vertex4;:H1,V",
"Vertex4;:H2,V",
"Edge1;:H1,E", "Edge1;:H2,E", "Edge1;:H3,E", "Edge2;:H1,E", "Edge2;:H2,E",
"Edge2;:H3,E", "Edge3;:H1,E", "Edge3;:H2,E", "Edge3;:H3,E", "Edge4;:H1,E",
"Edge4;:H2,E", "Edge4;:H3,E", "Face1;:H2,F", "Face1;:H3,F", "Face1;:H4,F",
"Face1;:H5,F", "Face1;:H6,F", "Vertex1;:H1,V", "Vertex1;:H2,V", "Vertex2;:H1,V",
"Vertex2;:H2,V", "Vertex3;:H1,V", "Vertex3;:H2,V", "Vertex4;:H1,V", "Vertex4;:H2,V",
}));
}