Skip to content

Commit 7a520a4

Browse files
committed
Toponaming/Part: Clean and add tests for FeatureMirroring and FeatureOffset
1 parent b4bb924 commit 7a520a4

File tree

6 files changed

+295
-8
lines changed

6 files changed

+295
-8
lines changed

src/Mod/Part/App/FeatureMirroring.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,11 @@ App::DocumentObjectExecReturn *Mirroring::execute()
252252
Base::Vector3d norm = Normal.getValue();
253253

254254
try {
255+
gp_Ax2 ax2(gp_Pnt(base.x,base.y,base.z), gp_Dir(norm.x,norm.y,norm.z));
256+
#ifndef FC_USE_TNP_FIX
255257
const TopoDS_Shape& shape = Feature::getShape(link);
256258
if (shape.IsNull())
257259
Standard_Failure::Raise(std::string(std::string(this->getFullLabel()) + ": Cannot mirror empty shape").c_str());
258-
gp_Ax2 ax2(gp_Pnt(base.x,base.y,base.z), gp_Dir(norm.x,norm.y,norm.z));
259-
#ifndef FC_USE_TNP_FIX
260260
gp_Trsf mat;
261261
mat.SetMirror(ax2);
262262
TopLoc_Location loc = shape.Location();
@@ -266,9 +266,9 @@ App::DocumentObjectExecReturn *Mirroring::execute()
266266
this->Shape.setValue(mkTrf.Shape());
267267
return App::DocumentObject::StdReturn;
268268
#else
269-
// auto shape = Feature::getTopoShape(link);
270-
// if (shape.isNull())
271-
// Standard_Failure::Raise("Cannot mirror empty shape");
269+
auto shape = Feature::getTopoShape(link);
270+
if (shape.isNull())
271+
Standard_Failure::Raise("Cannot mirror empty shape");
272272
this->Shape.setValue(TopoShape(0).makeElementMirror(shape,ax2));
273273
return Part::Feature::execute();
274274
#endif

src/Mod/Part/App/FeatureOffset.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ App::DocumentObjectExecReturn *Offset::execute()
9595
auto shape = Feature::getTopoShape(source);
9696
if(shape.isNull())
9797
return new App::DocumentObjectExecReturn("Invalid source link");
98-
auto join = static_cast<TopoShape::JoinType>(Join.getValue());
98+
auto join = static_cast<JoinType>(Join.getValue());
9999
this->Shape.setValue(TopoShape(0).makeElementOffset(
100-
shape,offset,tol,inter,self,mode,join,fill));
100+
shape,offset,tol,inter,self,mode,join,fill ? FillType::fill : FillType::noFill));
101101
#endif
102102
return App::DocumentObject::StdReturn;
103103
}

tests/src/Mod/Part/App/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ target_sources(
88
${CMAKE_CURRENT_SOURCE_DIR}/FeatureCompound.cpp
99
${CMAKE_CURRENT_SOURCE_DIR}/FeatureExtrusion.cpp
1010
${CMAKE_CURRENT_SOURCE_DIR}/FeatureFillet.cpp
11+
${CMAKE_CURRENT_SOURCE_DIR}/FeatureMirroring.cpp
12+
${CMAKE_CURRENT_SOURCE_DIR}/FeatureOffset.cpp
1113
${CMAKE_CURRENT_SOURCE_DIR}/FeaturePartBoolean.cpp
1214
${CMAKE_CURRENT_SOURCE_DIR}/FeaturePartCommon.cpp
1315
${CMAKE_CURRENT_SOURCE_DIR}/FeaturePartCut.cpp
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
// SPDX-License-Identifier: LGPL-2.1-or-later
2+
3+
#include "gtest/gtest.h"
4+
5+
#include <src/App/InitApplication.h>
6+
#include <Mod/Part/App/FeatureMirroring.h>
7+
8+
#include "PartTestHelpers.h"
9+
10+
using namespace PartTestHelpers;
11+
12+
// NOLINTBEGIN(readability-magic-numbers,cppcoreguidelines-avoid-magic-numbers)
13+
class FeatureMirroringTest: public ::testing::Test, public PartTestHelperClass
14+
{
15+
protected:
16+
static void SetUpTestSuite()
17+
{
18+
tests::initApplication();
19+
}
20+
21+
void SetUp() override
22+
{
23+
createTestDoc();
24+
_mirror = dynamic_cast<Part::Mirroring*>(_doc->addObject("Part::Mirroring"));
25+
_mirror->Source.setValue(_boxes[0]);
26+
_mirror->Base.setValue(1, 0, 0);
27+
_mirror->execute();
28+
}
29+
30+
void TearDown() override
31+
{}
32+
33+
Part::Mirroring* _mirror = nullptr; // NOLINT Can't be private in a test framework
34+
};
35+
36+
TEST_F(FeatureMirroringTest, testXMirror)
37+
{
38+
// Arrange
39+
Base::BoundBox3d bb = _mirror->Shape.getShape().getBoundBox();
40+
// Assert size and position
41+
EXPECT_EQ(getVolume(_mirror->Shape.getShape().getShape()), 6);
42+
// Mirrored it around X from 0,0,0 -> 1,2,3 to 0,0,-3 -> 1,2,0
43+
EXPECT_TRUE(boxesMatch(bb, Base::BoundBox3d(0, 0, -3, 1, 2, 0)));
44+
// Assert correct element Map
45+
#ifdef FC_USE_TNP_FIX
46+
EXPECT_TRUE(allElementsMatch(
47+
_mirror->Shape.getShape(),
48+
{
49+
"Edge10;:M;MIR;:H70c:7,E", "Edge11;:M;MIR;:H70c:7,E", "Edge12;:M;MIR;:H70c:7,E",
50+
"Edge1;:M;MIR;:H70c:7,E", "Edge2;:M;MIR;:H70c:7,E", "Edge3;:M;MIR;:H70c:7,E",
51+
"Edge4;:M;MIR;:H70c:7,E", "Edge5;:M;MIR;:H70c:7,E", "Edge6;:M;MIR;:H70c:7,E",
52+
"Edge7;:M;MIR;:H70c:7,E", "Edge8;:M;MIR;:H70c:7,E", "Edge9;:M;MIR;:H70c:7,E",
53+
"Face1;:M;MIR;:H70c:7,F", "Face2;:M;MIR;:H70c:7,F", "Face3;:M;MIR;:H70c:7,F",
54+
"Face4;:M;MIR;:H70c:7,F", "Face5;:M;MIR;:H70c:7,F", "Face6;:M;MIR;:H70c:7,F",
55+
"Vertex1;:M;MIR;:H70c:7,V", "Vertex2;:M;MIR;:H70c:7,V", "Vertex3;:M;MIR;:H70c:7,V",
56+
"Vertex4;:M;MIR;:H70c:7,V", "Vertex5;:M;MIR;:H70c:7,V", "Vertex6;:M;MIR;:H70c:7,V",
57+
"Vertex7;:M;MIR;:H70c:7,V", "Vertex8;:M;MIR;:H70c:7,V",
58+
}));
59+
#else
60+
EXPECT_EQ(_mirror->Shape.getShape().getElementMapSize(), 0);
61+
#endif
62+
}
63+
64+
TEST_F(FeatureMirroringTest, testYMirrorWithExistingElementMap)
65+
{
66+
// Arrange
67+
Part::Fuse* _fuse = nullptr; // NOLINT Can't be private in a test framework
68+
_fuse = dynamic_cast<Part::Fuse*>(_doc->addObject("Part::Fuse"));
69+
_fuse->Base.setValue(_boxes[0]);
70+
_fuse->Tool.setValue(_boxes[1]);
71+
// Act
72+
_fuse->execute();
73+
_mirror->Source.setValue(_fuse);
74+
_mirror->Base.setValue(0, 1, 0); // Y Axis
75+
Part::TopoShape ts = _fuse->Shape.getValue();
76+
double volume = getVolume(ts.getShape());
77+
Base::BoundBox3d bb = _mirror->Shape.getShape().getBoundBox();
78+
// Assert size and position
79+
EXPECT_EQ(getVolume(_mirror->Shape.getShape().getShape()), volume);
80+
// Mirrored it around X from 0,0,0 -> 1,2,3 to 0,0,-3 -> 1,2,0
81+
EXPECT_TRUE(boxesMatch(bb, Base::BoundBox3d(0, 0, -3, 1, 3, 0)));
82+
// Assert correct element Map
83+
#ifdef FC_USE_TNP_FIX
84+
EXPECT_TRUE(elementsMatch(
85+
_mirror->Shape.getShape(),
86+
{
87+
"Edge10;:M;FUS;:H30a:7,E;:M;MIR;:H310:7,E",
88+
"Edge11;:M;FUS;:H309:7,E;:M;MIR;:H310:7,E",
89+
"Edge12;:M;FUS;:H309:7,E;:M;MIR;:H310:7,E",
90+
"Edge1;:M;FUS;:H30a:7,E;:M;MIR;:H310:7,E",
91+
"Edge1;:M;FUS;:H30a:7,E;:U2;FUS;:H30a:8,V;:M;MIR;:H310:7,V",
92+
"Edge1;:M;FUS;:H30a:7,E;:U;FUS;:H30a:7,V;:M;MIR;:H310:7,V",
93+
"Edge2;:M2(Edge2;:H30a,E);FUS;:H309:17,E;:M;MIR;:H310:7,E",
94+
"Edge2;:M2(Edge2;:H30a,E);FUS;:H309:17,E;:U2;FUS;:H309:8,V;:M;MIR;:H310:7,V",
95+
"Edge2;:M2;FUS;:H30a:8,E;:M;MIR;:H310:7,E",
96+
"Edge2;:M2;FUS;:H30a:8,E;:U2;FUS;:H30a:8,V;:M;MIR;:H310:7,V",
97+
"Edge2;:M;FUS;:H309:7,E;:M;MIR;:H310:7,E",
98+
"Edge2;:M;FUS;:H309:7,E;:U;FUS;:H309:7,V;:M;MIR;:H310:7,V",
99+
"Edge3;:M;FUS;:H309:7,E;:M;MIR;:H310:7,E",
100+
"Edge3;:M;FUS;:H309:7,E;:U2;FUS;:H309:8,V;:M;MIR;:H310:7,V",
101+
"Edge4;:M2(Edge4;:H30a,E);FUS;:H309:17,E;:M;MIR;:H310:7,E",
102+
"Edge4;:M2;FUS;:H30a:8,E;:M;MIR;:H310:7,E",
103+
"Edge4;:M2;FUS;:H30a:8,E;:U2;FUS;:H30a:8,V;:M;MIR;:H310:7,V",
104+
"Edge4;:M;FUS;:H309:7,E;:M;MIR;:H310:7,E",
105+
"Edge4;:M;FUS;:H309:7,E;:U;FUS;:H309:7,V;:M;MIR;:H310:7,V",
106+
"Edge5;:M;FUS;:H30a:7,E;:M;MIR;:H310:7,E",
107+
"Edge5;:M;FUS;:H30a:7,E;:U2;FUS;:H30a:8,V;:M;MIR;:H310:7,V",
108+
"Edge5;:M;FUS;:H30a:7,E;:U;FUS;:H30a:7,V;:M;MIR;:H310:7,V",
109+
"Edge6;:M2(Edge6;:H30a,E);FUS;:H309:17,E;:M;MIR;:H310:7,E",
110+
"Edge6;:M2(Edge6;:H30a,E);FUS;:H309:17,E;:U2;FUS;:H309:8,V;:M;MIR;:H310:7,V",
111+
"Edge6;:M2;FUS;:H30a:8,E;:M;MIR;:H310:7,E",
112+
"Edge6;:M2;FUS;:H30a:8,E;:U2;FUS;:H30a:8,V;:M;MIR;:H310:7,V",
113+
"Edge6;:M;FUS;:H309:7,E;:M;MIR;:H310:7,E",
114+
"Edge6;:M;FUS;:H309:7,E;:U;FUS;:H309:7,V;:M;MIR;:H310:7,V",
115+
"Edge7;:M;FUS;:H309:7,E;:M;MIR;:H310:7,E",
116+
"Edge7;:M;FUS;:H309:7,E;:U2;FUS;:H309:8,V;:M;MIR;:H310:7,V",
117+
"Edge8;:M2(Edge8;:H30a,E);FUS;:H309:17,E;:M;MIR;:H310:7,E",
118+
"Edge8;:M2;FUS;:H30a:8,E;:M;MIR;:H310:7,E",
119+
"Edge8;:M2;FUS;:H30a:8,E;:U2;FUS;:H30a:8,V;:M;MIR;:H310:7,V",
120+
"Edge8;:M;FUS;:H309:7,E;:M;MIR;:H310:7,E",
121+
"Edge8;:M;FUS;:H309:7,E;:U;FUS;:H309:7,V;:M;MIR;:H310:7,V",
122+
"Edge9;:M;FUS;:H30a:7,E;:M;MIR;:H310:7,E",
123+
// TODO: Testing the Faces here was non-deterministic from run to run. Is that okay?
124+
}));
125+
#else
126+
EXPECT_EQ(_mirror->Shape.getShape().getElementMapSize(), 0);
127+
#endif
128+
}
129+
130+
// NOLINTEND(readability-magic-numbers,cppcoreguidelines-avoid-magic-numbers)
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
// SPDX-License-Identifier: LGPL-2.1-or-later
2+
3+
#include "gtest/gtest.h"
4+
5+
#include <src/App/InitApplication.h>
6+
7+
#include "PartTestHelpers.h"
8+
#include "Mod/Part/App/FeatureOffset.h"
9+
10+
using namespace PartTestHelpers;
11+
12+
// NOLINTBEGIN(readability-magic-numbers,cppcoreguidelines-avoid-magic-numbers)
13+
class FeatureOffsetTest: public ::testing::Test, public PartTestHelperClass
14+
{
15+
protected:
16+
static void SetUpTestSuite()
17+
{
18+
tests::initApplication();
19+
}
20+
21+
void SetUp() override
22+
{
23+
createTestDoc();
24+
_offset = dynamic_cast<Part::Offset*>(_doc->addObject("Part::Offset"));
25+
_offset->Source.setValue(_boxes[0]);
26+
_offset->Value.setValue(1);
27+
_offset->Join.setValue((int)JoinType::intersection);
28+
_offset->execute();
29+
}
30+
31+
void TearDown() override
32+
{}
33+
34+
Part::Offset* _offset = nullptr; // NOLINT Can't be private in a test framework
35+
};
36+
37+
TEST_F(FeatureOffsetTest, testOffset3D)
38+
{
39+
// Arrange
40+
Base::BoundBox3d bb = _offset->Shape.getShape().getBoundBox();
41+
// Assert size and position
42+
// a 1x2x3 box 3doffset by 1 becomes a 3x4x5 box, so volume is 60.
43+
EXPECT_EQ(getVolume(_offset->Shape.getShape().getShape()), 60);
44+
EXPECT_TRUE(boxesMatch(bb, Base::BoundBox3d(-1, -1, -1, 2, 3, 4)));
45+
// Assert correct element Map
46+
#ifdef FC_USE_TNP_FIX
47+
EXPECT_TRUE(allElementsMatch(
48+
_offset->Shape.getShape(),
49+
{
50+
"Edge10;:G;OFS;:H47b:7,E", "Edge11;:G;OFS;:H47b:7,E", "Edge12;:G;OFS;:H47b:7,E",
51+
"Edge1;:G;OFS;:H47b:7,E", "Edge2;:G;OFS;:H47b:7,E", "Edge3;:G;OFS;:H47b:7,E",
52+
"Edge4;:G;OFS;:H47b:7,E", "Edge5;:G;OFS;:H47b:7,E", "Edge6;:G;OFS;:H47b:7,E",
53+
"Edge7;:G;OFS;:H47b:7,E", "Edge8;:G;OFS;:H47b:7,E", "Edge9;:G;OFS;:H47b:7,E",
54+
"Face1;:G;OFS;:H47b:7,F", "Face2;:G;OFS;:H47b:7,F", "Face3;:G;OFS;:H47b:7,F",
55+
"Face4;:G;OFS;:H47b:7,F", "Face5;:G;OFS;:H47b:7,F", "Face6;:G;OFS;:H47b:7,F",
56+
"Vertex1;:G;OFS;:H47b:7,V", "Vertex2;:G;OFS;:H47b:7,V", "Vertex3;:G;OFS;:H47b:7,V",
57+
"Vertex4;:G;OFS;:H47b:7,V", "Vertex5;:G;OFS;:H47b:7,V", "Vertex6;:G;OFS;:H47b:7,V",
58+
"Vertex7;:G;OFS;:H47b:7,V", "Vertex8;:G;OFS;:H47b:7,V",
59+
}));
60+
#else
61+
EXPECT_EQ(_offset->Shape.getShape().getElementMapSize(), 0);
62+
#endif
63+
}
64+
65+
TEST_F(FeatureOffsetTest, testOffset3DWithExistingElementMap)
66+
{
67+
// Arrange
68+
Part::Fuse* _fuse = nullptr; // NOLINT Can't be private in a test framework
69+
_fuse = dynamic_cast<Part::Fuse*>(_doc->addObject("Part::Fuse"));
70+
_fuse->Base.setValue(_boxes[0]);
71+
_fuse->Tool.setValue(_boxes[1]);
72+
_fuse->Refine.setValue(true);
73+
// Act
74+
_fuse->execute();
75+
_offset->Source.setValue(_fuse);
76+
_offset->Value.setValue(2);
77+
_offset->execute();
78+
Base::BoundBox3d bb = _offset->Shape.getShape().getBoundBox();
79+
// Assert size and position
80+
// A 1x3x3 box 3doffset by 2 becomes a 5x7x7 box with volume of 245
81+
EXPECT_EQ(getVolume(_fuse->Shape.getShape().getShape()), 9);
82+
EXPECT_EQ(getVolume(_offset->Shape.getShape().getShape()), 245);
83+
EXPECT_TRUE(boxesMatch(bb, Base::BoundBox3d(-2, -2, -2, 3, 5, 5)));
84+
// Assert correct element Map
85+
#ifdef FC_USE_TNP_FIX
86+
EXPECT_TRUE(elementsMatch(
87+
_offset->Shape.getShape(),
88+
{
89+
"Edge2;:M2(Edge2;:H366,E);FUS;:H365:17,E;:G(Edge2;:M2;FUS;:H366:8,E;K-1;:H366:4,E|"
90+
"Edge2;:M;FUS;:H365:7,E;K-1;:H365:4,E);RFI;:H365:53,E;:G;OFS;:H36c:7,E;SLD;:H36c:4,E",
91+
"Edge2;:M2(Edge2;:H366,E);FUS;:H365:17,E;:G(Edge2;:M2;FUS;:H366:8,E;K-1;:H366:4,E|"
92+
"Edge2;:M;FUS;:H365:7,E;K-1;:H365:4,E);RFI;:H365:53,E;:U2;RFI;:H365:8,V;:G;OFS;:H36c:7,"
93+
"V;SLD;:H36c:4,V",
94+
"Edge2;:M2(Edge2;:H366,E);FUS;:H365:17,E;:G(Edge2;:M2;FUS;:H366:8,E;K-1;:H366:4,E|"
95+
"Edge2;:M;FUS;:H365:7,E;K-1;:H365:4,E);RFI;:H365:53,E;:U;RFI;:H365:7,V;:G;OFS;:H36c:7,"
96+
"V;SLD;:H36c:4,V",
97+
"Edge4;:M2(Edge4;:H366,E);FUS;:H365:17,E;:G(Edge4;:M2;FUS;:H366:8,E;K-1;:H366:4,E|"
98+
"Edge4;:M;FUS;:H365:7,E;K-1;:H365:4,E);RFI;:H365:53,E;:G;OFS;:H36c:7,E;SLD;:H36c:4,E",
99+
"Edge4;:M2(Edge4;:H366,E);FUS;:H365:17,E;:G(Edge4;:M2;FUS;:H366:8,E;K-1;:H366:4,E|"
100+
"Edge4;:M;FUS;:H365:7,E;K-1;:H365:4,E);RFI;:H365:53,E;:U2;RFI;:H365:8,V;:G;OFS;:H36c:7,"
101+
"V;SLD;:H36c:4,V",
102+
"Edge4;:M2(Edge4;:H366,E);FUS;:H365:17,E;:G(Edge4;:M2;FUS;:H366:8,E;K-1;:H366:4,E|"
103+
"Edge4;:M;FUS;:H365:7,E;K-1;:H365:4,E);RFI;:H365:53,E;:U;RFI;:H365:7,V;:G;OFS;:H36c:7,"
104+
"V;SLD;:H36c:4,V",
105+
"Edge6;:M2(Edge6;:H366,E);FUS;:H365:17,E;:G(Edge6;:M2;FUS;:H366:8,E;K-1;:H366:4,E|"
106+
"Edge6;:M;FUS;:H365:7,E;K-1;:H365:4,E);RFI;:H365:53,E;:G;OFS;:H36c:7,E;SLD;:H36c:4,E",
107+
"Edge6;:M2(Edge6;:H366,E);FUS;:H365:17,E;:G(Edge6;:M2;FUS;:H366:8,E;K-1;:H366:4,E|"
108+
"Edge6;:M;FUS;:H365:7,E;K-1;:H365:4,E);RFI;:H365:53,E;:U2;RFI;:H365:8,V;:G;OFS;:H36c:7,"
109+
"V;SLD;:H36c:4,V",
110+
"Edge6;:M2(Edge6;:H366,E);FUS;:H365:17,E;:G(Edge6;:M2;FUS;:H366:8,E;K-1;:H366:4,E|"
111+
"Edge6;:M;FUS;:H365:7,E;K-1;:H365:4,E);RFI;:H365:53,E;:U;RFI;:H365:7,V;:G;OFS;:H36c:7,"
112+
"V;SLD;:H36c:4,V",
113+
"Edge8;:M2(Edge8;:H366,E);FUS;:H365:17,E;:G(Edge8;:M2;FUS;:H366:8,E;K-1;:H366:4,E|"
114+
"Edge8;:M;FUS;:H365:7,E;K-1;:H365:4,E);RFI;:H365:53,E;:G;OFS;:H36c:7,E;SLD;:H36c:4,E",
115+
"Edge8;:M2(Edge8;:H366,E);FUS;:H365:17,E;:G(Edge8;:M2;FUS;:H366:8,E;K-1;:H366:4,E|"
116+
"Edge8;:M;FUS;:H365:7,E;K-1;:H365:4,E);RFI;:H365:53,E;:U2;RFI;:H365:8,V;:G;OFS;:H36c:7,"
117+
"V;SLD;:H36c:4,V",
118+
"Edge8;:M2(Edge8;:H366,E);FUS;:H365:17,E;:G(Edge8;:M2;FUS;:H366:8,E;K-1;:H366:4,E|"
119+
"Edge8;:M;FUS;:H365:7,E;K-1;:H365:4,E);RFI;:H365:53,E;:U;RFI;:H365:7,V;:G;OFS;:H36c:7,"
120+
"V;SLD;:H36c:4,V",
121+
// TODO: Testing the Faces here was non-deterministic from run to run. Is that okay?
122+
}));
123+
#else
124+
EXPECT_EQ(_offset->Shape.getShape().getElementMapSize(), 0);
125+
#endif
126+
}
127+
128+
TEST_F(FeatureOffsetTest, testOffset2D)
129+
{
130+
// Arrange
131+
Part::Offset2D* _offset2 = dynamic_cast<Part::Offset2D*>(_doc->addObject("Part::Offset2D"));
132+
Part::Plane* _pln = dynamic_cast<Part::Plane*>(_doc->addObject("Part::Plane"));
133+
_pln->Length.setValue(2);
134+
_pln->Width.setValue(3);
135+
_offset2->Source.setValue(_pln);
136+
_offset2->Value.setValue(1);
137+
_offset2->Join.setValue((int)JoinType::intersection);
138+
// Act
139+
_offset2->execute();
140+
Base::BoundBox3d bb = _offset2->Shape.getShape().getBoundBox();
141+
// Assert size and position
142+
// a 2x3 face 2doffset by 1 becomes a 4x5 face, so area is 20.
143+
EXPECT_EQ(getArea(_offset2->Shape.getShape().getShape()), 20);
144+
EXPECT_TRUE(boxesMatch(bb, Base::BoundBox3d(-1, -1, 0, 3, 4, 0)));
145+
// Assert correct element Map
146+
EXPECT_EQ(_offset2->Shape.getShape().getElementMapSize(), 0);
147+
}
148+
149+
// NOLINTEND(readability-magic-numbers,cppcoreguidelines-avoid-magic-numbers)

tests/src/Mod/Part/App/PartTestHelpers.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,13 @@ testing::AssertionResult elementsMatch(const TopoShape& shape,
175175
[&, name](const Data::MappedElement& element) {
176176
return matchStringsWithoutClause(element.name.toString(),
177177
name,
178-
";D[a-fA-F0-9]+");
178+
"(;D|;:H|;K)-?[a-fA-F0-9]+");
179+
// ;D ;:H and ;K are the sections of an encoded name for
180+
// Duplicate, Tag and a Face name in slices. All three of these
181+
// can vary from run to run or platform to platform, as they are
182+
// based on either explicit random numbers or memory addresses.
183+
// Thus we remove the value from comparisons and just check that
184+
// they exist.
179185
})
180186
== elements.end()) {
181187
return testing::AssertionFailure() << mappedElementVectorToString(elements);

0 commit comments

Comments
 (0)