Skip to content

Commit 261fae8

Browse files
committed
Modeling, Bnd_BoxTest - Replace test fixture with standalone tests for Bnd_Box
1 parent 0d30c93 commit 261fae8

1 file changed

Lines changed: 41 additions & 53 deletions

File tree

src/FoundationClasses/TKMath/GTests/Bnd_Box_Test.cxx

Lines changed: 41 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,11 @@
1111
#include <cmath>
1212
#include <limits>
1313

14-
// Test fixture for Bnd_Box tests
15-
class Bnd_BoxTest : public ::testing::Test
16-
{
17-
protected:
18-
void SetUp() override
19-
{
20-
myTolerance = 1e-10;
21-
}
22-
23-
Standard_Real myTolerance;
24-
};
25-
2614
//==================================================================================================
2715
// Constructor Tests
2816
//==================================================================================================
2917

30-
TEST_F(Bnd_BoxTest, DefaultConstructor)
18+
TEST(Bnd_BoxTest, DefaultConstructor)
3119
{
3220
Bnd_Box aBox;
3321

@@ -36,7 +24,7 @@ TEST_F(Bnd_BoxTest, DefaultConstructor)
3624
EXPECT_DOUBLE_EQ(0.0, aBox.GetGap()) << "Default gap should be 0.0";
3725
}
3826

39-
TEST_F(Bnd_BoxTest, PointConstructor)
27+
TEST(Bnd_BoxTest, PointConstructor)
4028
{
4129
gp_Pnt aMinPnt(1.0, 2.0, 3.0);
4230
gp_Pnt aMaxPnt(4.0, 5.0, 6.0);
@@ -61,7 +49,7 @@ TEST_F(Bnd_BoxTest, PointConstructor)
6149
// Set and Update Tests
6250
//==================================================================================================
6351

64-
TEST_F(Bnd_BoxTest, SetWithPoint)
52+
TEST(Bnd_BoxTest, SetWithPoint)
6553
{
6654
Bnd_Box aBox;
6755
gp_Pnt aPnt(1.5, 2.5, 3.5);
@@ -81,7 +69,7 @@ TEST_F(Bnd_BoxTest, SetWithPoint)
8169
EXPECT_DOUBLE_EQ(3.5, aZmax) << "Point coordinates should set both min and max";
8270
}
8371

84-
TEST_F(Bnd_BoxTest, SetWithPointAndDirection)
72+
TEST(Bnd_BoxTest, SetWithPointAndDirection)
8573
{
8674
Bnd_Box aBox;
8775
gp_Pnt aPnt(1.0, 2.0, 3.0);
@@ -94,7 +82,7 @@ TEST_F(Bnd_BoxTest, SetWithPointAndDirection)
9482
EXPECT_FALSE(aBox.IsOpenXmin()) << "Box should not be open in negative X direction";
9583
}
9684

97-
TEST_F(Bnd_BoxTest, UpdateWithBounds)
85+
TEST(Bnd_BoxTest, UpdateWithBounds)
9886
{
9987
Bnd_Box aBox;
10088

@@ -113,7 +101,7 @@ TEST_F(Bnd_BoxTest, UpdateWithBounds)
113101
EXPECT_DOUBLE_EQ(6.0, aZmax) << "Update should set correct bounds";
114102
}
115103

116-
TEST_F(Bnd_BoxTest, UpdateWithPoint)
104+
TEST(Bnd_BoxTest, UpdateWithPoint)
117105
{
118106
Bnd_Box aBox;
119107

@@ -136,7 +124,7 @@ TEST_F(Bnd_BoxTest, UpdateWithPoint)
136124
EXPECT_DOUBLE_EQ(2.5, aYmax) << "Box should expand to include new point";
137125
}
138126

139-
TEST_F(Bnd_BoxTest, UpdateExpansion)
127+
TEST(Bnd_BoxTest, UpdateExpansion)
140128
{
141129
Bnd_Box aBox;
142130
aBox.Update(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
@@ -159,7 +147,7 @@ TEST_F(Bnd_BoxTest, UpdateExpansion)
159147
// Gap and Tolerance Tests
160148
//==================================================================================================
161149

162-
TEST_F(Bnd_BoxTest, GapOperations)
150+
TEST(Bnd_BoxTest, GapOperations)
163151
{
164152
Bnd_Box aBox;
165153

@@ -182,7 +170,7 @@ TEST_F(Bnd_BoxTest, GapOperations)
182170
// Corner Methods Tests
183171
//==================================================================================================
184172

185-
TEST_F(Bnd_BoxTest, CornerMethods)
173+
TEST(Bnd_BoxTest, CornerMethods)
186174
{
187175
Bnd_Box aBox;
188176
aBox.Update(1.0, 2.0, 3.0, 4.0, 5.0, 6.0);
@@ -200,15 +188,15 @@ TEST_F(Bnd_BoxTest, CornerMethods)
200188
EXPECT_DOUBLE_EQ(6.1, aCornerMax.Z()) << "CornerMax should account for gap";
201189
}
202190

203-
TEST_F(Bnd_BoxTest, CornerMethodsVoidBox)
191+
TEST(Bnd_BoxTest, CornerMethodsVoidBox)
204192
{
205193
Bnd_Box aBox; // void box
206194

207195
EXPECT_THROW(aBox.CornerMin(), Standard_ConstructionError) << "CornerMin should throw for void box";
208196
EXPECT_THROW(aBox.CornerMax(), Standard_ConstructionError) << "CornerMax should throw for void box";
209197
}
210198

211-
TEST_F(Bnd_BoxTest, CornerMethodsOpenBox)
199+
TEST(Bnd_BoxTest, CornerMethodsOpenBox)
212200
{
213201
Bnd_Box aBox;
214202
aBox.Update(1.0, 2.0, 3.0, 4.0, 5.0, 6.0);
@@ -226,7 +214,7 @@ TEST_F(Bnd_BoxTest, CornerMethodsOpenBox)
226214
// Thin Methods Tests
227215
//==================================================================================================
228216

229-
TEST_F(Bnd_BoxTest, ThinnessMethods)
217+
TEST(Bnd_BoxTest, ThinnessMethods)
230218
{
231219
Bnd_Box aBox;
232220

@@ -253,7 +241,7 @@ TEST_F(Bnd_BoxTest, ThinnessMethods)
253241
EXPECT_TRUE(aThinBox.IsThin(0.1)) << "Box thin in all dimensions should be overall thin";
254242
}
255243

256-
TEST_F(Bnd_BoxTest, ThinnessWithOpenBox)
244+
TEST(Bnd_BoxTest, ThinnessWithOpenBox)
257245
{
258246
Bnd_Box aBox;
259247
aBox.Update(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
@@ -270,7 +258,7 @@ TEST_F(Bnd_BoxTest, ThinnessWithOpenBox)
270258
// Transformation Tests
271259
//==================================================================================================
272260

273-
TEST_F(Bnd_BoxTest, TransformationIdentity)
261+
TEST(Bnd_BoxTest, TransformationIdentity)
274262
{
275263
Bnd_Box aBox;
276264
aBox.Update(1.0, 2.0, 3.0, 4.0, 5.0, 6.0);
@@ -294,7 +282,7 @@ TEST_F(Bnd_BoxTest, TransformationIdentity)
294282
EXPECT_DOUBLE_EQ(aBox.GetGap(), aTransformed.GetGap()) << "Gap should be preserved";
295283
}
296284

297-
TEST_F(Bnd_BoxTest, TransformationTranslation)
285+
TEST(Bnd_BoxTest, TransformationTranslation)
298286
{
299287
Bnd_Box aBox;
300288
aBox.Update(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
@@ -315,7 +303,7 @@ TEST_F(Bnd_BoxTest, TransformationTranslation)
315303
EXPECT_DOUBLE_EQ(5.0, aZmax) << "Translation should shift coordinates";
316304
}
317305

318-
TEST_F(Bnd_BoxTest, TransformationVoidBox)
306+
TEST(Bnd_BoxTest, TransformationVoidBox)
319307
{
320308
Bnd_Box aVoidBox;
321309
gp_Trsf aRotation;
@@ -330,7 +318,7 @@ TEST_F(Bnd_BoxTest, TransformationVoidBox)
330318
// Add Methods Tests
331319
//==================================================================================================
332320

333-
TEST_F(Bnd_BoxTest, AddBox)
321+
TEST(Bnd_BoxTest, AddBox)
334322
{
335323
Bnd_Box aBox1;
336324
aBox1.Update(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
@@ -355,7 +343,7 @@ TEST_F(Bnd_BoxTest, AddBox)
355343
EXPECT_DOUBLE_EQ(0.2, aBox1.GetGap()) << "Gap should be maximum of both boxes";
356344
}
357345

358-
TEST_F(Bnd_BoxTest, AddVoidBox)
346+
TEST(Bnd_BoxTest, AddVoidBox)
359347
{
360348
Bnd_Box aBox;
361349
aBox.Update(1.0, 1.0, 1.0, 2.0, 2.0, 2.0);
@@ -370,7 +358,7 @@ TEST_F(Bnd_BoxTest, AddVoidBox)
370358
EXPECT_DOUBLE_EQ(2.0, aXmax) << "Adding void box should not change original";
371359
}
372360

373-
TEST_F(Bnd_BoxTest, AddToVoidBox)
361+
TEST(Bnd_BoxTest, AddToVoidBox)
374362
{
375363
Bnd_Box aVoidBox;
376364
Bnd_Box aBox;
@@ -387,7 +375,7 @@ TEST_F(Bnd_BoxTest, AddToVoidBox)
387375
EXPECT_DOUBLE_EQ(2.0, aXmax) << "Should adopt added box's bounds";
388376
}
389377

390-
TEST_F(Bnd_BoxTest, AddPoint)
378+
TEST(Bnd_BoxTest, AddPoint)
391379
{
392380
Bnd_Box aBox;
393381
aBox.Update(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
@@ -406,7 +394,7 @@ TEST_F(Bnd_BoxTest, AddPoint)
406394
EXPECT_DOUBLE_EQ(1.0, aZmax) << "Box should maintain existing bounds";
407395
}
408396

409-
TEST_F(Bnd_BoxTest, AddDirection)
397+
TEST(Bnd_BoxTest, AddDirection)
410398
{
411399
Bnd_Box aBox;
412400
aBox.Update(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
@@ -420,7 +408,7 @@ TEST_F(Bnd_BoxTest, AddDirection)
420408
EXPECT_FALSE(aBox.IsOpenYmin()) << "X direction should not affect Y";
421409
}
422410

423-
TEST_F(Bnd_BoxTest, AddPointWithDirection)
411+
TEST(Bnd_BoxTest, AddPointWithDirection)
424412
{
425413
Bnd_Box aBox;
426414
gp_Pnt aPnt(1.0, 2.0, 3.0);
@@ -437,7 +425,7 @@ TEST_F(Bnd_BoxTest, AddPointWithDirection)
437425
// IsOut Methods Tests
438426
//==================================================================================================
439427

440-
TEST_F(Bnd_BoxTest, IsOutPoint)
428+
TEST(Bnd_BoxTest, IsOutPoint)
441429
{
442430
Bnd_Box aBox;
443431
aBox.Update(0.0, 0.0, 0.0, 2.0, 2.0, 2.0);
@@ -451,7 +439,7 @@ TEST_F(Bnd_BoxTest, IsOutPoint)
451439
EXPECT_FALSE(aBox.IsOut(aBoundaryPnt)) << "Point on boundary should not be out";
452440
}
453441

454-
TEST_F(Bnd_BoxTest, IsOutPointWithGap)
442+
TEST(Bnd_BoxTest, IsOutPointWithGap)
455443
{
456444
Bnd_Box aBox;
457445
aBox.Update(0.0, 0.0, 0.0, 2.0, 2.0, 2.0);
@@ -464,15 +452,15 @@ TEST_F(Bnd_BoxTest, IsOutPointWithGap)
464452
EXPECT_TRUE(aBox.IsOut(aFarBoundaryPnt)) << "Point beyond gap should be out";
465453
}
466454

467-
TEST_F(Bnd_BoxTest, IsOutVoidBox)
455+
TEST(Bnd_BoxTest, IsOutVoidBox)
468456
{
469457
Bnd_Box aVoidBox;
470458
gp_Pnt anAnyPnt(1.0, 2.0, 3.0);
471459

472460
EXPECT_TRUE(aVoidBox.IsOut(anAnyPnt)) << "Void box should exclude all points";
473461
}
474462

475-
TEST_F(Bnd_BoxTest, IsOutWholeBox)
463+
TEST(Bnd_BoxTest, IsOutWholeBox)
476464
{
477465
Bnd_Box aWholeBox;
478466
aWholeBox.SetWhole();
@@ -482,7 +470,7 @@ TEST_F(Bnd_BoxTest, IsOutWholeBox)
482470
EXPECT_FALSE(aWholeBox.IsOut(anAnyPnt)) << "Whole box should include all points";
483471
}
484472

485-
TEST_F(Bnd_BoxTest, IsOutBox)
473+
TEST(Bnd_BoxTest, IsOutBox)
486474
{
487475
Bnd_Box aBox1;
488476
aBox1.Update(0.0, 0.0, 0.0, 2.0, 2.0, 2.0);
@@ -501,7 +489,7 @@ TEST_F(Bnd_BoxTest, IsOutBox)
501489
EXPECT_FALSE(aBox1.IsOut(aTouchingBox)) << "Touching boxes should not be out";
502490
}
503491

504-
TEST_F(Bnd_BoxTest, IsOutPlane)
492+
TEST(Bnd_BoxTest, IsOutPlane)
505493
{
506494
Bnd_Box aBox;
507495
aBox.Update(-1.0, -1.0, -1.0, 1.0, 1.0, 1.0);
@@ -516,7 +504,7 @@ TEST_F(Bnd_BoxTest, IsOutPlane)
516504
EXPECT_TRUE(aBox.IsOut(aSeparatePln)) << "Separate plane should be out";
517505
}
518506

519-
TEST_F(Bnd_BoxTest, IsOutLine)
507+
TEST(Bnd_BoxTest, IsOutLine)
520508
{
521509
Bnd_Box aBox;
522510
aBox.Update(0.0, 0.0, 0.0, 2.0, 2.0, 2.0);
@@ -535,7 +523,7 @@ TEST_F(Bnd_BoxTest, IsOutLine)
535523
// Distance Method Tests
536524
//==================================================================================================
537525

538-
TEST_F(Bnd_BoxTest, Distance)
526+
TEST(Bnd_BoxTest, Distance)
539527
{
540528
Bnd_Box aBox1;
541529
aBox1.Update(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
@@ -558,7 +546,7 @@ TEST_F(Bnd_BoxTest, Distance)
558546
// Open/Close Methods Tests
559547
//==================================================================================================
560548

561-
TEST_F(Bnd_BoxTest, OpenCloseMethods)
549+
TEST(Bnd_BoxTest, OpenCloseMethods)
562550
{
563551
Bnd_Box aBox;
564552
aBox.Update(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
@@ -587,7 +575,7 @@ TEST_F(Bnd_BoxTest, OpenCloseMethods)
587575
// Void/Whole State Tests
588576
//==================================================================================================
589577

590-
TEST_F(Bnd_BoxTest, VoidWholeStates)
578+
TEST(Bnd_BoxTest, VoidWholeStates)
591579
{
592580
Bnd_Box aBox;
593581

@@ -614,7 +602,7 @@ TEST_F(Bnd_BoxTest, VoidWholeStates)
614602
// Edge Cases and Error Conditions
615603
//==================================================================================================
616604

617-
TEST_F(Bnd_BoxTest, EdgeCases)
605+
TEST(Bnd_BoxTest, EdgeCases)
618606
{
619607
Bnd_Box aBox;
620608

@@ -632,7 +620,7 @@ TEST_F(Bnd_BoxTest, EdgeCases)
632620
EXPECT_TRUE(aSmallBox.IsXThin(1e-9)) << "Very small box should be considered thin";
633621
}
634622

635-
TEST_F(Bnd_BoxTest, TransformationWithOpenBox)
623+
TEST(Bnd_BoxTest, TransformationWithOpenBox)
636624
{
637625
Bnd_Box aBox;
638626
aBox.Update(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
@@ -651,7 +639,7 @@ TEST_F(Bnd_BoxTest, TransformationWithOpenBox)
651639
// Additional Coverage Tests
652640
//==================================================================================================
653641

654-
TEST_F(Bnd_BoxTest, SquareExtent)
642+
TEST(Bnd_BoxTest, SquareExtent)
655643
{
656644
Bnd_Box aBox;
657645
aBox.Update(0.0, 0.0, 0.0, 2.0, 3.0, 4.0);
@@ -662,7 +650,7 @@ TEST_F(Bnd_BoxTest, SquareExtent)
662650
EXPECT_DOUBLE_EQ(29.0, aBox.SquareExtent()) << "Square extent should be square of diagonal length";
663651
}
664652

665-
TEST_F(Bnd_BoxTest, SetVoidAndWholeTransitions)
653+
TEST(Bnd_BoxTest, SetVoidAndWholeTransitions)
666654
{
667655
Bnd_Box aBox;
668656
aBox.Update(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
@@ -677,7 +665,7 @@ TEST_F(Bnd_BoxTest, SetVoidAndWholeTransitions)
677665
EXPECT_FALSE(aBox.IsVoid()) << "Whole box should not be void";
678666
}
679667

680-
TEST_F(Bnd_BoxTest, DirectOpenOperations)
668+
TEST(Bnd_BoxTest, DirectOpenOperations)
681669
{
682670
Bnd_Box aBox;
683671
aBox.Update(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
@@ -702,7 +690,7 @@ TEST_F(Bnd_BoxTest, DirectOpenOperations)
702690
EXPECT_TRUE(aBox.IsOpenZmax()) << "OpenZmax should work";
703691
}
704692

705-
TEST_F(Bnd_BoxTest, IsOutWithTransformation)
693+
TEST(Bnd_BoxTest, IsOutWithTransformation)
706694
{
707695
Bnd_Box aBox1;
708696
aBox1.Update(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
@@ -718,7 +706,7 @@ TEST_F(Bnd_BoxTest, IsOutWithTransformation)
718706
EXPECT_FALSE(aBox1.IsOut(aBox2, aTransf)) << "Overlapping transformed boxes should not be out";
719707
}
720708

721-
TEST_F(Bnd_BoxTest, IsOutWithTwoTransformations)
709+
TEST(Bnd_BoxTest, IsOutWithTwoTransformations)
722710
{
723711
Bnd_Box aBox1;
724712
aBox1.Update(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
@@ -733,7 +721,7 @@ TEST_F(Bnd_BoxTest, IsOutWithTwoTransformations)
733721
EXPECT_TRUE(aBox1.IsOut(aT1, aBox2, aT2)) << "Separated transformed boxes should be out";
734722
}
735723

736-
TEST_F(Bnd_BoxTest, IsOutLineSegment)
724+
TEST(Bnd_BoxTest, IsOutLineSegment)
737725
{
738726
Bnd_Box aBox;
739727
aBox.Update(0.0, 0.0, 0.0, 2.0, 2.0, 2.0);
@@ -752,7 +740,7 @@ TEST_F(Bnd_BoxTest, IsOutLineSegment)
752740
EXPECT_TRUE(aBox.IsOut(aP3, aP4, aDir)) << "Line segment missing box should be out";
753741
}
754742

755-
TEST_F(Bnd_BoxTest, UpdateExpandsCorrectly)
743+
TEST(Bnd_BoxTest, UpdateExpandsCorrectly)
756744
{
757745
Bnd_Box aBox;
758746

0 commit comments

Comments
 (0)