[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot]
2023-12-23 10:55:15 +00:00
parent f81ce9d2e1
commit e344a2fe42
5 changed files with 44 additions and 37 deletions

View File

@@ -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<int, std::vector<int>>;
using List = std::vector<int>;
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<Part::ShapeHistory> hist = _common->History.getValues();

View File

@@ -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.
// See FeaturePartCommon.cpp for a history test. It would be exactly the same and redundant here.

View File

@@ -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<Part::TopoShape> subs = ts.getSubTopoShapes(TopAbs_FACE); // TopAbs_WIRE alternate approach
std::vector<Part::TopoShape> 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.
// See FeaturePartCommon.cpp for a history test. It would be exactly the same and redundant here.

View File

@@ -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<Base::Vector3d, 6> 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<Base::Vector3d, 6> 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<Part::Box*>(_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<Part::Box*>(_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

View File

@@ -16,7 +16,7 @@ class PartTestHelperClass
public:
App::Document* _doc;
std::string _docName;
std::array<Part::Box *, 6> _boxes;
std::array<Part::Box*, 6> _boxes;
void createTestDoc();
};