diff --git a/tests/src/Mod/Part/App/FeaturePartCommon.cpp b/tests/src/Mod/Part/App/FeaturePartCommon.cpp index d379df6b5c..673a697a3d 100644 --- a/tests/src/Mod/Part/App/FeaturePartCommon.cpp +++ b/tests/src/Mod/Part/App/FeaturePartCommon.cpp @@ -112,13 +112,15 @@ TEST_F(FeaturePartCommonTest, testBarelyIntersecting) _common->execute(); Part::TopoShape ts = _common->Shape.getValue(); double volume = PartTestHelpers::getVolume(ts.getShape()); - double target = Base::Precision::Confusion() * 3 * 1000; // Reduce precision to 1e04 over 3 dimensions + double target = + Base::Precision::Confusion() * 3 * 1000; // Reduce precision to 1e04 over 3 dimensions Base::BoundBox3d bb = ts.getBoundBox(); // Assert - // Using FLOAT, not DOUBLE here so test library comparison is of reasonable precision 1e07 rather than 1e15 - // See https://google.github.io/googletest/reference/assertions.html#floating-point - EXPECT_FLOAT_EQ(volume, target); // Should be approximately 0.00029999999999996696 + // Using FLOAT, not DOUBLE here so test library comparison is of reasonable precision 1e07 + // rather than 1e15 See + // https://google.github.io/googletest/reference/assertions.html#floating-point + EXPECT_FLOAT_EQ(volume, target); // Should be approximately 0.00029999999999996696 // double check using bounds: EXPECT_DOUBLE_EQ(bb.MinX, 0.0); EXPECT_DOUBLE_EQ(bb.MinY, 1.9999); @@ -164,9 +166,9 @@ TEST_F(FeaturePartCommonTest, testHistory) using MapList = std::map>; using List = std::vector; MapList compare1 = - {{0, List {0}}, {1, List {5}}, {2, List () }, {3, List {2}}, {4, List {3}}, {5, List {1}}}; + {{0, List {0}}, {1, List {5}}, {2, List()}, {3, List {2}}, {4, List {3}}, {5, List {1}}}; MapList compare2 = - {{0, List {0}}, {1, List {5}}, {2, List {4}}, {3, List () }, {4, List {3}}, {5, List {1}}}; + {{0, List {0}}, {1, List {5}}, {2, List {4}}, {3, List()}, {4, List {3}}, {5, List {1}}}; // Act and Assert no histories yet std::vector hist = _common->History.getValues(); diff --git a/tests/src/Mod/Part/App/FeaturePartCut.cpp b/tests/src/Mod/Part/App/FeaturePartCut.cpp index 798785c0da..f512c69f53 100644 --- a/tests/src/Mod/Part/App/FeaturePartCut.cpp +++ b/tests/src/Mod/Part/App/FeaturePartCut.cpp @@ -129,12 +129,14 @@ TEST_F(FeaturePartCutTest, testBarelyIntersecting) _cut->execute(); Part::TopoShape ts = _cut->Shape.getValue(); double volume = PartTestHelpers::getVolume(ts.getShape()); - double target = 6 - Base::Precision::Confusion() * 3 * 1000; // Reduce precision to 1e04 over 3 dimensions + double target = + 6 - Base::Precision::Confusion() * 3 * 1000; // Reduce precision to 1e04 over 3 dimensions Base::BoundBox3d bb = ts.getBoundBox(); // Assert - // Using FLOAT, not DOUBLE here so test library comparison is of reasonable precision 1e07 rather than 1e15 - // See https://google.github.io/googletest/reference/assertions.html#floating-point + // Using FLOAT, not DOUBLE here so test library comparison is of reasonable precision 1e07 + // rather than 1e15 See + // https://google.github.io/googletest/reference/assertions.html#floating-point EXPECT_FLOAT_EQ(volume, target); // double check using bounds: EXPECT_DOUBLE_EQ(bb.MinX, 0.0); @@ -172,4 +174,4 @@ TEST_F(FeaturePartCutTest, testGetProviderName) EXPECT_STREQ(name, "PartGui::ViewProviderBoolean"); } -// See FeaturePartCommon.cpp for a history test. It would be exactly the same and redundant here. \ No newline at end of file +// See FeaturePartCommon.cpp for a history test. It would be exactly the same and redundant here. diff --git a/tests/src/Mod/Part/App/FeaturePartFuse.cpp b/tests/src/Mod/Part/App/FeaturePartFuse.cpp index 304e02f9a4..a9db9b4b8b 100644 --- a/tests/src/Mod/Part/App/FeaturePartFuse.cpp +++ b/tests/src/Mod/Part/App/FeaturePartFuse.cpp @@ -130,12 +130,14 @@ TEST_F(FeaturePartFuseTest, testBarelyIntersecting) _fuse->execute(); Part::TopoShape ts = _fuse->Shape.getValue(); double volume = PartTestHelpers::getVolume(ts.getShape()); - double target = 12 - Base::Precision::Confusion() * 3 * 1000; // Reduce precision to 1e04 over 3 dimensions + double target = + 12 - Base::Precision::Confusion() * 3 * 1000; // Reduce precision to 1e04 over 3 dimensions Base::BoundBox3d bb = ts.getBoundBox(); // Assert - // Using FLOAT, not DOUBLE here so test library comparison is of reasonable precision 1e07 rather than 1e15 - // See https://google.github.io/googletest/reference/assertions.html#floating-point + // Using FLOAT, not DOUBLE here so test library comparison is of reasonable precision 1e07 + // rather than 1e15 See + // https://google.github.io/googletest/reference/assertions.html#floating-point EXPECT_FLOAT_EQ(volume, target); // double check using bounds: EXPECT_DOUBLE_EQ(bb.MinX, 0.0); @@ -182,7 +184,8 @@ TEST_F(FeaturePartFuseTest, testRefine) // Act _fuse->execute(); Part::TopoShape ts = _fuse->Shape.getValue(); - std::vector subs = ts.getSubTopoShapes(TopAbs_FACE); // TopAbs_WIRE alternate approach + std::vector subs = + ts.getSubTopoShapes(TopAbs_FACE); // TopAbs_WIRE alternate approach // Assert two boxes, plus redundant faces at the joint. EXPECT_EQ(subs.size(), 14); // Act @@ -194,4 +197,4 @@ TEST_F(FeaturePartFuseTest, testRefine) EXPECT_EQ(subs.size(), 6); } -// See FeaturePartCommon.cpp for a history test. It would be exactly the same and redundant here. \ No newline at end of file +// See FeaturePartCommon.cpp for a history test. It would be exactly the same and redundant here. diff --git a/tests/src/Mod/Part/App/PartTestHelpers.cpp b/tests/src/Mod/Part/App/PartTestHelpers.cpp index 26d4532649..ab8d8f60ec 100644 --- a/tests/src/Mod/Part/App/PartTestHelpers.cpp +++ b/tests/src/Mod/Part/App/PartTestHelpers.cpp @@ -13,30 +13,30 @@ double getVolume(TopoDS_Shape shape) void PartTestHelperClass::createTestDoc() { - _docName = App::GetApplication().getUniqueDocumentName("test"); - _doc = App::GetApplication().newDocument(_docName.c_str(), "testUser"); - std::array box_origins = { - Base::Vector3d(), // First box at 0,0,0 - Base::Vector3d(0, 1, 0), // Overlap with first box - Base::Vector3d(0, 3, 0), // Don't Overlap with first box - Base::Vector3d(0, 2, 0), // Touch the first box - Base::Vector3d(0, 2 + Base::Precision::Confusion(), 0), // Just Outside of touching - // For just inside of touching, go enough that precision rounding doesn't make us overlap. - Base::Vector3d(0, 2 - Base::Precision::Confusion() * 1000, 0) - }; + _docName = App::GetApplication().getUniqueDocumentName("test"); + _doc = App::GetApplication().newDocument(_docName.c_str(), "testUser"); + std::array box_origins = { + Base::Vector3d(), // First box at 0,0,0 + Base::Vector3d(0, 1, 0), // Overlap with first box + Base::Vector3d(0, 3, 0), // Don't Overlap with first box + Base::Vector3d(0, 2, 0), // Touch the first box + Base::Vector3d(0, 2 + Base::Precision::Confusion(), 0), // Just Outside of touching + // For just inside of touching, go enough that precision rounding doesn't make us overlap. + Base::Vector3d(0, 2 - Base::Precision::Confusion() * 1000, 0)}; - // for (auto& [box, origin] : zip(_boxes, box_origins) ) { - // for ( int i : range(0,_boxes.size())) { - for ( unsigned i=0; i < _boxes.size(); i++ ) { - auto box = _boxes[i] = static_cast(_doc->addObject("Part::Box")); - box->Length.setValue(1); - box->Width.setValue(2); - box->Height.setValue(3); - box->Placement.setValue(Base::Placement(box_origins[i], Base::Rotation(), Base::Vector3d() ) ); - } + // for (auto& [box, origin] : zip(_boxes, box_origins) ) { + // for ( int i : range(0,_boxes.size())) { + for (unsigned i = 0; i < _boxes.size(); i++) { + auto box = _boxes[i] = static_cast(_doc->addObject("Part::Box")); + box->Length.setValue(1); + box->Width.setValue(2); + box->Height.setValue(3); + box->Placement.setValue( + Base::Placement(box_origins[i], Base::Rotation(), Base::Vector3d())); + } } -} +} // namespace PartTestHelpers // https://google.github.io/googletest/advanced.html#teaching-googletest-how-to-print-your-values namespace Part diff --git a/tests/src/Mod/Part/App/PartTestHelpers.h b/tests/src/Mod/Part/App/PartTestHelpers.h index 15ed44da69..0adbea84de 100644 --- a/tests/src/Mod/Part/App/PartTestHelpers.h +++ b/tests/src/Mod/Part/App/PartTestHelpers.h @@ -16,7 +16,7 @@ class PartTestHelperClass public: App::Document* _doc; std::string _docName; - std::array _boxes; + std::array _boxes; void createTestDoc(); };