File size: 27,571 Bytes
985c397
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
// SPDX-License-Identifier: LGPL-2.1-or-later

#include "gtest/gtest.h"
#include <gmock/gmock.h>

#include <src/App/InitApplication.h>

#include <App/Application.h>
#include <App/Document.h>
#include <App/DocumentObject.h>
#include <App/DocumentObserver.h>
#include <App/ElementNamingUtils.h>
#include <Base/Interpreter.h>

using namespace App;
using namespace Data;

class DISABLED_DocumentObserverTest: public ::testing::Test
{
protected:
    static void SetUpTestSuite()
    {
        tests::initApplication();
    }

    void SetUp() override
    {
        _docName = App::GetApplication().getUniqueDocumentName("test");
        _doc = App::GetApplication().newDocument(_docName.c_str(), "testUser");
    }

    void TearDown() override
    {
        App::GetApplication().closeDocument(_docName.c_str());
    }

    // NOLINTBEGIN(cppcoreguidelines-non-private-member-variables-in-classes)
    std::string _docName {};
    App::Document* _doc {};
    // NOLINTEND(cppcoreguidelines-non-private-member-variables-in-classes)
};

TEST_F(DISABLED_DocumentObserverTest, hasSubObject)
{
    // Arrange

    // An App::SubObjectT() object with a subname that doesn't contain a sub object name
    auto subObjTWithoutSubObj {SubObjectT()};
    // An App::SubObjectT() object with a subname that contains a sub object name
    auto subObjTWithSubObj {SubObjectT()};

    // A subname that doesn't contain a sub object name
    auto subObjTNameWithoutSubObj {"Line"};
    // A subname that contains a sub object name
    auto subObjTNameWithSubObj {std::string()};
    subObjTNameWithSubObj += subObjTNameWithoutSubObj;
    subObjTNameWithSubObj += ".Edge1";

    // A variable used to store the result of the call to the method SubObjectT::hasSubObject() by
    // the object subObjTWithoutSubObj
    auto hasNoSubObj {false};
    // A variable used to store the result of the call to the method SubObjectT::hasSubObject() by
    // the object subObjTWithSubObj
    auto hasSubObj {false};

    // Setting the subnames of the App::SubObjectT() objects defined previously
    subObjTWithoutSubObj.setSubName(subObjTNameWithoutSubObj);
    subObjTWithSubObj.setSubName(subObjTNameWithSubObj.c_str());

    // Act

    hasNoSubObj = subObjTWithoutSubObj.hasSubObject();
    hasSubObj = subObjTWithSubObj.hasSubObject();

    // Assert

    // The subname of subObjTWithoutSubObj doesn't contain the name of a sub object, therefore
    // hasNoSubObj should be false
    EXPECT_FALSE(hasNoSubObj);

    // The subname of subObjTWithSubObj doesn't contain the name of a sub object, therefore
    // hasSubObj should be true
    EXPECT_TRUE(hasSubObj);
}

TEST_F(DISABLED_DocumentObserverTest, hasSubElement)
{
    // Arrange

    // An App::SubObjectT() object with a subname that doesn't contain a sub element name
    auto subObjTWithoutSubEl {SubObjectT()};
    // An App::SubObjectT() object with a subname that contains a sub element name
    auto subObjTWithSubEl {SubObjectT()};

    // A subname that doesn't contain a sub element name
    auto subObjTNameWithoutSubEl {"Sketch."};
    // A subname that contains a sub element name
    auto subObjTNameWithSubEl {std::string()};
    subObjTNameWithSubEl += subObjTNameWithoutSubEl;
    subObjTNameWithSubEl += ELEMENT_MAP_PREFIX;
    subObjTNameWithSubEl += "e1.ExternalEdge1";

    // A variable used to store the result of the call to the method SubObjectT::hasSubElement() by
    // the object subObjTWithoutSubEl
    auto hasNoSubEl {false};
    // A variable used to store the result of the call to the method SubObjectT::hasSubElement() by
    // the object subObjTWithSubEl
    auto hasSubEl {false};

    // Setting the subnames of the App::SubObjectT() objects defined previously
    subObjTWithoutSubEl.setSubName(subObjTNameWithoutSubEl);
    subObjTWithSubEl.setSubName(subObjTNameWithSubEl.c_str());

    // Act

    hasNoSubEl = subObjTWithoutSubEl.hasSubElement();
    hasSubEl = subObjTWithSubEl.hasSubElement();

    // Assert

    // The subname of subObjTWithoutSubEl doesn't contain the name of a sub element, therefore
    // hasNoSubEl should be false
    EXPECT_FALSE(hasNoSubEl);

    // The subname of subObjTWithSubEl doesn't contain the name of a sub element, therefore hasSubEl
    // should be true
    EXPECT_TRUE(hasSubEl);
}

TEST_F(DISABLED_DocumentObserverTest, normalize)
{
    // Arrange

    // A Part::Box added to the document
    auto box {_doc->addObject("Part::Box")};
    // The name of the Part::Box added to the document
    auto boxName {box->getNameInDocument()};
    // Changing the label of the Part::Box to test the differences between calling
    // SubObjectT::normalized() with the options argument set to
    // SubObjectT::NormalizeOption::KeepSubName or set to other values
    box->Label.setValue("Cube");
    // The label of the Part::Box added to the document
    auto boxLabel {box->Label.getValue()};
    // The name of a Part::Cylinder added to the document
    auto cylName {_doc->addObject("Part::Cylinder")->getNameInDocument()};
    // An App::Part added to the document
    auto part {_doc->addObject("App::Part")};
    // The name of the App::Part added to the document
    auto partName {part->getNameInDocument()};
    // An App::LinkGroup added to the document
    auto lGrp {_doc->addObject("App::LinkGroup")};
    // The name of the App::LinkGroup added to the document
    auto lGrpName {lGrp->getNameInDocument()};
    // The name of the object used as argument for various calls of the constructors of
    // App::SubObjectT objects
    auto subName {std::string()};
    // A helper string used to compose the argument of some calls of
    // Base::Interpreter().runString()
    auto cmd {std::string()};

    // Performing a fusion to create an object that will be added to the App::Part object and
    // linked inside the App::LinkGroup object
    Base::Interpreter().runString("from BOPTools import BOPFeatures");
    Base::Interpreter().runString("bp = BOPFeatures.BOPFeatures(App.activeDocument())");
    cmd = "bp.make_multi_fuse([\"";
    cmd += boxName;
    cmd += "\", \"";
    cmd += cylName;
    cmd += "\", ])";
    Base::Interpreter().runString(cmd.c_str());
    Base::Interpreter().runString("App.ActiveDocument.recompute()");
    // The name of the fusion object
    auto fuseName {_doc->getObject("Fusion")->getNameInDocument()};

    // Adding the fusion to the App::Part object to test the differences between calling
    // SubObjectT::normalize() with the options argument set to
    // SubObjectT::NormalizeOption::NoFlatten or set to other values
    cmd = "App.ActiveDocument.getObject(\"";
    cmd += partName;
    cmd += "\").addObject(App.ActiveDocument.getObject(\"";
    cmd += fuseName;
    cmd += "\"))";
    Base::Interpreter().runString(cmd.c_str());
    Base::Interpreter().runString("App.ActiveDocument.recompute()");

    // Adding the fusion to the App::LinkGroup object to test SubObjectT::normalize() with the
    // options argument set to SubObjectT::NormalizeOption::ConvertIndex
    cmd = "App.ActiveDocument.getObject(\"";
    cmd += lGrpName;
    cmd += "\").setLink(App.ActiveDocument.getObject(\"";
    cmd += partName;
    cmd += "\"))";
    Base::Interpreter().runString(cmd.c_str());
    Base::Interpreter().runString("App.ActiveDocument.recompute()");

    // Defining the name of the object that will be used as argument for various calls of the
    // constructors of App::SubObjectT objects
    subName = partName;
    subName += ".";
    subName += fuseName;
    subName += ".";
    subName += boxName;
    subName += ".Edge1";

    // An empty App::SubObjectT object
    auto subObjTEmpty {SubObjectT()};
    // An App::SubObjectT object without sub objects
    auto subObjTWithoutSubObj {SubObjectT(box, boxName)};
    // An App::SubObjectT object with sub objects
    auto subObjTWithSubObj {SubObjectT(lGrp, subName.c_str())};
    // An App::SubObjectT object used to test SubObjectT::normalize() with the option argument set
    // to SubObjectT::NormalizeOption::NoElement
    auto subObjTWithoutEl {SubObjectT(lGrp, subName.c_str())};
    // An App::SubObjectT object used to test SubObjectT::normalize() with the option argument set
    // to SubObjectT::NormalizeOption::NoFlatten
    auto subObjTNoFlatten {SubObjectT(lGrp, subName.c_str())};
    // An App::SubObjectT object used to test SubObjectT::normalize() with the option argument set
    // to SubObjectT::NormalizeOption::KeepSubName
    // The subName is modified replacing "Part__Box" with "$Cube" to test the effect of using
    // SubObjectT::NormalizeOption::KeepSubName, that is leaving the "$Cube" instead of replacing it
    // with the name of the DocumentObject with that label ("Part__Box")
    auto subObjTKeepSubName {SubObjectT(
        lGrp,
        subName
            .replace(
                strlen(partName) + strlen(fuseName) + 2,
                strlen(boxName),
                std::string("$").append(boxLabel).c_str()
            )
            .c_str()
    )};
    // An App::SubObjectT object used to test SubObjectT::normalize() with the option argument set
    // to SubObjectT::NormalizeOption::ConvertIndex
    // The subName is modified replacing "App_Part" with "0" to test the effect of using
    // SubObjectT::NormalizeOption::ConvertIndex, that is replacing the "0" with the name of the
    // DocumentObject at position 0 of lGrp
    auto subObjTConvertIndex {SubObjectT(lGrp, subName.replace(0, strlen(partName), "0").c_str())};

    // A bool variable used to store the result of subObjTEmpty.normalize()
    auto normalizeEmpty {false};
    // A bool variable used to store the result of subObjTWithoutSubObj.normalize()
    auto normalizeWithoutSubObj {false};
    // A bool variable used to store the result of subObjTWithSubObj.normalize()
    auto normalizeWithSubObj {false};
    // A bool variable used to store the result of subObjTWithoutEl.normalize()
    auto normalizeWithoutEl {false};
    // A bool variable used to store the result of subObjTNoFlatten.normalize()
    auto normalizeNoFlatten {false};
    // A bool variable used to store the result of subObjTKeepSubName.normalize()
    auto normalizeKeepSubName {false};
    // A bool variable used to store the result of subObjTConvertIndex.normalize()
    auto normalizeConvertIndex {false};

    // Act

    normalizeEmpty = subObjTEmpty.normalize();
    normalizeWithoutSubObj = subObjTWithoutSubObj.normalize();
    normalizeWithSubObj = subObjTWithSubObj.normalize();
    normalizeWithoutEl = subObjTWithoutEl.normalize(SubObjectT::NormalizeOption::NoElement);
    normalizeNoFlatten = subObjTNoFlatten.normalize(SubObjectT::NormalizeOption::NoFlatten);
    normalizeKeepSubName = subObjTKeepSubName.normalize(SubObjectT::NormalizeOption::KeepSubName);
    normalizeConvertIndex = subObjTConvertIndex.normalize(SubObjectT::NormalizeOption::ConvertIndex);

    // Assert

    // In this case calling SubObjectT::normalize() doesn't have effect as subObjTEmpty has been
    // initialized with an empty constructor
    EXPECT_FALSE(normalizeEmpty);

    // In this case calling SubObjectT::normalize() doesn't have effect as subObjTWithoutSubObj
    // hasn't any sub objects
    EXPECT_FALSE(normalizeWithoutSubObj);

    // In this case calling SubObjectT::normalize() changes subObjTWithSubObj subname in this way:
    // The "Fusion." part of the of the original subname is removed because the
    // SubObjectT::NormalizeOption::NoFlatten flag isn't set;
    // The "Edge1" part of the of the original subname is kept because the
    // SubObjectT::NormalizeOption::NoElement flag isn't set;
    EXPECT_TRUE(normalizeWithSubObj);

    // In this case calling SubObjectT::normalize() changes subObjTWithoutEl subname in this way:
    // The "Fusion." part of the of the original subname is removed because the
    // SubObjectT::NormalizeOption::NoFlatten flag isn't set;
    // The "Edge1" part of the of the original subname is removed because the
    // SubObjectT::NormalizeOption::NoElement flag is set;
    EXPECT_TRUE(normalizeWithoutEl);

    // In this case calling SubObjectT::normalize() doesn't have effect as neither the
    // DocumentObject referenced nor the subname of subObjTNoFlatten are changed
    EXPECT_FALSE(normalizeNoFlatten);

    // In this case calling SubObjectT::normalize() changes subObjTKeepSubName subname in this way:
    // The "Fusion." part of the of the original subname is removed because the
    // SubObjectT::NormalizeOption::NoFlatten flag isn't set;
    // The "$Cube." part of the of the original subname is kept because the
    // SubObjectT::NormalizeOption::KeepSubName flag is set;
    // The "Edge1" part of the of the original subname is kept because the
    // SubObjectT::NormalizeOption::NoElement flag isn't set;
    EXPECT_TRUE(normalizeKeepSubName);

    // In this case calling SubObjectT::normalize() changes subObjTConvertIndex subname in this way:
    // The "0." part of the of the original subname is replaced with "App__Part" because the
    // SubObjectT::NormalizeOption::ConvertIndex flag is set;
    // The "Fusion." part of the of the original subname is removed because the
    // SubObjectT::NormalizeOption::NoFlatten flag isn't set;
    // The "$Cube." part of the of the original subname is replaced with "Part__Box." because the
    // SubObjectT::NormalizeOption::KeepSubName flag isn't set;
    // The "Edge1" part of the of the original subname is kept because the
    // SubObjectT::NormalizeOption::NoElement flag isn't set;
    EXPECT_TRUE(normalizeConvertIndex);
}

TEST_F(DISABLED_DocumentObserverTest, normalized)
{
    // Arrange

    // A Part::Box added to the document
    auto box {_doc->addObject("Part::Box")};
    // The name of the Part::Box added to the document
    auto boxName {box->getNameInDocument()};
    // Changing the label of the Part::Box to test the differences between calling
    // SubObjectT::normalized() with the options argument set to
    // SubObjectT::NormalizeOption::KeepSubName or set to other values
    box->Label.setValue("Cube");
    // The label of the Part::Box added to the document
    auto boxLabel {box->Label.getValue()};
    // The name of a Part::Cylinder added to the document
    auto cylName {_doc->addObject("Part::Cylinder")->getNameInDocument()};
    // An App::Part added to the document
    auto part {_doc->addObject("App::Part")};
    // The name of the App::Part added to the document
    auto partName {part->getNameInDocument()};
    // An App::LinkGroup added to the document
    auto lGrp {_doc->addObject("App::LinkGroup")};
    // The name of the App::LinkGroup added to the document
    auto lGrpName {lGrp->getNameInDocument()};

    // The name of the object used as argument for various calls of the constructors of
    // App::SubObjectT objects
    auto subName {std::string()};
    // A helper string used to compose the argument of some calls of
    // Base::Interpreter().runString()
    auto cmd {std::string()};

    // Performing a fusion to create an object that will be added to the App::Part object and
    // linked inside the App::LinkGroup object
    Base::Interpreter().runString("from BOPTools import BOPFeatures");
    Base::Interpreter().runString("bp = BOPFeatures.BOPFeatures(App.activeDocument())");
    cmd = "bp.make_multi_fuse([\"";
    cmd += boxName;
    cmd += "\", \"";
    cmd += cylName;
    cmd += "\", ])";
    Base::Interpreter().runString(cmd.c_str());
    Base::Interpreter().runString("App.ActiveDocument.recompute()");
    // The name of the fusion object
    auto fuseName {_doc->getObject("Fusion")->getNameInDocument()};

    // Adding the fusion to the App::Part object to test the differences between calling
    // SubObjectT::normalized() with the options argument set to
    // SubObjectT::NormalizeOption::NoFlatten or set to other values
    cmd = "App.ActiveDocument.getObject(\"";
    cmd += partName;
    cmd += "\").addObject(App.ActiveDocument.getObject(\"";
    cmd += fuseName;
    cmd += "\"))";
    Base::Interpreter().runString(cmd.c_str());
    Base::Interpreter().runString("App.ActiveDocument.recompute()");

    // Creating a Link Array with the App::Part object added to the document to test
    // SubObjectT::normalized() with the options argument set to
    // SubObjectT::NormalizeOption::ConvertIndex or set to other values
    Base::Interpreter().runString("import Draft");
    cmd = "_obj = Draft.make_ortho_array(App.ActiveDocument.";
    cmd += partName;
    cmd += ", v_x=FreeCAD.Vector(100.0, 0.0, 0.0), v_y=FreeCAD.Vector(0.0, 100.0, 0.0), "
           "v_z=FreeCAD.Vector(0.0, 0.0, 100.0), n_x=2, n_y=2, n_z=1, use_link=True)";
    Base::Interpreter().runString(cmd.c_str());
    cmd = "_obj.Fuse = False";
    Base::Interpreter().runString(cmd.c_str());
    cmd = "Draft.autogroup(_obj)";
    Base::Interpreter().runString(cmd.c_str());
    Base::Interpreter().runString("App.ActiveDocument.recompute()");
    auto lArr {_doc->getObject("Array")};
    auto lArrName {lArr->getNameInDocument()};

    // Adding the Link Array to the App::LinkGroup object to test SubObjectT::normalized() with the
    // options argument set to SubObjectT::NormalizeOption::ConvertIndex or set to other values
    cmd = "App.ActiveDocument.getObject(\"";
    cmd += lGrpName;
    cmd += "\").setLink(App.ActiveDocument.getObject(\"";
    cmd += lArrName;
    cmd += "\"))";
    Base::Interpreter().runString(cmd.c_str());
    Base::Interpreter().runString("App.ActiveDocument.recompute()");

    // Defining the name of the object that will be used as argument for various calls of the
    // constructors of App::SubObjectT objects
    subName = "0.";
    subName += "3.";
    subName += fuseName;
    subName += ".";
    subName += "$";
    subName += boxLabel;
    subName += ".";
    subName += "Edge1";

    // An empty App::SubObjectT object
    auto subObjTEmpty {SubObjectT()};
    // An App::SubObjectT object without sub objects
    auto subObjTWithoutSubObj {SubObjectT(box, boxName)};
    // An App::SubObjectT object with sub objects
    auto subObjTWithSubObj {SubObjectT(lGrp, subName.c_str())};
    // An App::SubObjectT object used to test SubObjectT::normalized() with the option argument set
    // to SubObjectT::NormalizeOption::NoElement
    auto subObjTWithoutEl {SubObjectT(lGrp, subName.c_str())};
    // An App::SubObjectT object used to test SubObjectT::normalized() with the option argument set
    // to SubObjectT::NormalizeOption::NoFlatten
    auto subObjTNoFlatten {SubObjectT(lGrp, subName.c_str())};
    // An App::SubObjectT object used to test SubObjectT::normalized() with the option argument set
    // to SubObjectT::NormalizeOption::KeepSubName
    auto subObjTKeepSubName {SubObjectT(lGrp, subName.c_str())};
    // An App::SubObjectT object used to test SubObjectT::normalized() with the option argument set
    // to SubObjectT::NormalizeOption::ConvertIndex
    auto subObjTConvertIndex {SubObjectT(lGrp, subName.c_str())};

    // An App::SubObjectT object used to store the result of subObjTEmpty.normalized()
    auto subObjTEmptyNormalized {SubObjectT()};
    // An App::SubObjectT object used to store the result of subObjTWithoutSubObj.normalized()
    auto subObjTWithoutSubObjNormalized {SubObjectT()};
    // An App::SubObjectT object used to store the result of subObjTWithSubObj.normalized()
    auto subObjTWithSubObjNormalized {SubObjectT()};
    // An App::SubObjectT object used to store the result of subObjTWithoutEl.normalized()
    auto subObjTWithoutElNormalized {SubObjectT()};
    // An App::SubObjectT object used to store the result of subObjTNoFlatten.normalized()
    auto subObjTNoFlattenNormalized {SubObjectT()};
    // An App::SubObjectT object used to store the result of subObjTKeepSubName.normalized()
    auto subObjTKeepSubNameNormalized {SubObjectT()};
    // An App::SubObjectT object used to store the result of subObjTConvertIndex.normalized()
    auto subObjTConvertIndexNormalized {SubObjectT()};

    // Act

    subObjTEmptyNormalized = subObjTEmpty.normalized();
    subObjTWithoutSubObjNormalized = subObjTWithoutSubObj.normalized();
    subObjTWithSubObjNormalized = subObjTWithSubObj.normalized();
    subObjTWithoutElNormalized = subObjTWithoutEl.normalized(SubObjectT::NormalizeOption::NoElement);
    subObjTNoFlattenNormalized = subObjTNoFlatten.normalized(SubObjectT::NormalizeOption::NoFlatten);
    subObjTKeepSubNameNormalized = subObjTKeepSubName.normalized(
        SubObjectT::NormalizeOption::KeepSubName
    );
    subObjTConvertIndexNormalized = subObjTConvertIndex.normalized(
        SubObjectT::NormalizeOption::ConvertIndex
    );

    // Assert

    // In this case calling SubObjectT::normalized() doesn't have effect as subObjTEmpty has been
    // initialized with an empty constructor
    EXPECT_EQ(subObjTEmpty.getSubName(), subObjTEmptyNormalized.getSubName());

    // In this case calling SubObjectT::normalized() doesn't have effect as subObjTWithoutSubObj
    // hasn't any sub objects
    EXPECT_EQ(subObjTWithoutSubObj.getSubName(), subObjTWithoutSubObjNormalized.getSubName());

    // In this case calling SubObjectT::normalized() changes subObjTWithSubObj subname in this way:
    // The "0." part of the of the original subname is kept because the
    // SubObjectT::NormalizeOption::ConvertIndex flag isn't set;
    // The "3." part of the of the original subname is kept because the
    // SubObjectT::NormalizeOption::ConvertIndex flag isn't set;
    // The "Fusion." part of the of the original subname is removed because the
    // SubObjectT::NormalizeOption::NoFlatten flag isn't set;
    // The "$Cube." part of the of the original subname is replaced with "Part__Box." because the
    // SubObjectT::NormalizeOption::KeepSubName flag isn't set;
    // The "Edge1" part of the of the original subname is kept because the
    // SubObjectT::NormalizeOption::NoElement flag isn't set;
    EXPECT_NE(subObjTWithSubObjNormalized.getSubName().find("0."), std::string::npos);
    EXPECT_EQ(subObjTWithSubObjNormalized.getSubName().find(fuseName), std::string::npos);
    EXPECT_EQ(subObjTWithSubObjNormalized.getSubName().find(boxLabel), std::string::npos);
    EXPECT_NE(subObjTWithSubObjNormalized.getSubName().find(boxName), std::string::npos);
    EXPECT_NE(subObjTWithSubObjNormalized.getSubName().find("Edge1"), std::string::npos);

    // In this case calling SubObjectT::normalized() changes subObjTWithoutEl subname in this way:
    // The "0." part of the of the original subname is kept because the
    // SubObjectT::NormalizeOption::ConvertIndex flag isn't set;
    // The "3." part of the of the original subname is kept because the
    // SubObjectT::NormalizeOption::ConvertIndex flag isn't set;
    // The "Fusion." part of the of the original subname is removed because the
    // SubObjectT::NormalizeOption::NoFlatten flag isn't set;
    // The "$Cube." part of the of the original subname is replaced with "Part__Box." because the
    // SubObjectT::NormalizeOption::KeepSubName flag isn't set;
    // The "Edge1" part of the of the original subname is removed because the
    // SubObjectT::NormalizeOption::NoElement flag is set;
    EXPECT_NE(subObjTWithoutElNormalized.getSubName().find("0."), std::string::npos);
    EXPECT_EQ(subObjTWithoutElNormalized.getSubName().find(fuseName), std::string::npos);
    EXPECT_EQ(subObjTWithoutElNormalized.getSubName().find(boxLabel), std::string::npos);
    EXPECT_NE(subObjTWithoutElNormalized.getSubName().find(boxName), std::string::npos);
    EXPECT_EQ(subObjTWithoutElNormalized.getSubName().find("Edge1"), std::string::npos);

    // In this case calling SubObjectT::normalized() changes subObjTNoFlatten subname in this way:
    // The "0." part of the of the original subname is kept because the
    // SubObjectT::NormalizeOption::ConvertIndex flag isn't set;
    // The "3." part of the of the original subname is kept because the
    // SubObjectT::NormalizeOption::ConvertIndex flag isn't set;
    // The "Fusion." part of the of the original subname is kept because the
    // SubObjectT::NormalizeOption::NoFlatten flag is set;
    // The "$Cube." part of the of the original subname is replaced with "Part__Box." because the
    // SubObjectT::NormalizeOption::KeepSubName flag isn't set;
    // The "Edge1" part of the of the original subname is kept because the
    // SubObjectT::NormalizeOption::NoElement flag isn't set;
    EXPECT_NE(subObjTNoFlattenNormalized.getSubName().find("0."), std::string::npos);
    EXPECT_NE(subObjTNoFlattenNormalized.getSubName().find(fuseName), std::string::npos);
    EXPECT_EQ(subObjTNoFlattenNormalized.getSubName().find(boxLabel), std::string::npos);
    EXPECT_NE(subObjTNoFlattenNormalized.getSubName().find(boxName), std::string::npos);
    EXPECT_NE(subObjTNoFlattenNormalized.getSubName().find("Edge1"), std::string::npos);

    // In this case calling SubObjectT::normalized() changes subObjTKeepSubName subname in this way:
    // The "0." part of the of the original subname is kept because the
    // SubObjectT::NormalizeOption::ConvertIndex flag isn't set;
    // The "3." part of the of the original subname is kept because the
    // SubObjectT::NormalizeOption::ConvertIndex flag isn't set;
    // The "Fusion." part of the of the original subname is removed because the
    // SubObjectT::NormalizeOption::NoFlatten flag isn't set;
    // The "$Cube." part of the of the original subname is kept because the
    // SubObjectT::NormalizeOption::KeepSubName flag is set;
    // The "Edge1" part of the of the original subname is kept because the
    // SubObjectT::NormalizeOption::NoElement flag isn't set;
    EXPECT_NE(subObjTKeepSubNameNormalized.getSubName().find("0."), std::string::npos);
    EXPECT_EQ(subObjTKeepSubNameNormalized.getSubName().find(fuseName), std::string::npos);
    EXPECT_NE(subObjTKeepSubNameNormalized.getSubName().find(boxLabel), std::string::npos);
    EXPECT_NE(subObjTKeepSubNameNormalized.getSubName().find("Edge1"), std::string::npos);

    // In this case calling SubObjectT::normalized() changes subObjTConvertIndex in this way:
    // The "0." part of the of the original subname is replaced with "Array." because the
    // SubObjectT::NormalizeOption::ConvertIndex flag is set;
    // The "3." part of the of the original subname is kept even if the
    // SubObjectT::NormalizeOption::ConvertIndex flag is set because it refers to a specific
    // DocumentObject of the "Array." DocumentObject;
    // The "Fusion." part of the of the original subname is removed because the
    // SubObjectT::NormalizeOption::NoFlatten flag isn't set;
    // The "$Cube." part of the of the original subname is replaced with "Part__Box." because the
    // SubObjectT::NormalizeOption::KeepSubName flag isn't set;
    // The "Edge1" part of the of the original subname is kept because the
    // SubObjectT::NormalizeOption::NoElement flag isn't set;
    EXPECT_EQ(subObjTConvertIndexNormalized.getSubName().find("0."), std::string::npos);
    EXPECT_NE(subObjTConvertIndexNormalized.getSubName().find(lArrName), std::string::npos);
    EXPECT_EQ(subObjTConvertIndexNormalized.getSubName().find(fuseName), std::string::npos);
    EXPECT_EQ(subObjTConvertIndexNormalized.getSubName().find(boxLabel), std::string::npos);
    EXPECT_NE(subObjTConvertIndexNormalized.getSubName().find(boxName), std::string::npos);
    EXPECT_NE(subObjTConvertIndexNormalized.getSubName().find("Edge1"), std::string::npos);
}