Adding additional TNP tests (#11829)
* Initial tests for Chamfer, Fillet, Compound * Lint cleanup, new tests * Outline of Extrusion and Revolution * Use python to define a 2d object to extrude and test * Refactor; start filling in revolution tests * Example of parameterized tests in Extrusion, cleanups * Use gtest framework for parameterised tests * Rearrange for clarity * WIP with TEST_P use for posterity * Switch from parameters to individual tests * Guess at test failures on other platforms * Cleanups and Revolution Tests * Remove temp code * Switch Revolutions to boundbox test; add Compound subshape count test * Calculate test volume correctly; lint fixes Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>
This commit is contained in:
59
tests/src/Mod/Part/App/FeatureCompound.cpp
Normal file
59
tests/src/Mod/Part/App/FeatureCompound.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "Mod/Part/App/FeatureCompound.h"
|
||||
#include <src/App/InitApplication.h>
|
||||
|
||||
#include "PartTestHelpers.h"
|
||||
|
||||
class FeatureCompoundTest: public ::testing::Test, public PartTestHelpers::PartTestHelperClass
|
||||
{
|
||||
protected:
|
||||
static void SetUpTestSuite()
|
||||
{
|
||||
tests::initApplication();
|
||||
}
|
||||
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
createTestDoc();
|
||||
_compound = dynamic_cast<Part::Compound*>(_doc->addObject("Part::Compound"));
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{}
|
||||
|
||||
Part::Compound* _compound = nullptr; // NOLINT Can't be private in a test framework
|
||||
};
|
||||
|
||||
TEST_F(FeatureCompoundTest, testIntersecting)
|
||||
{
|
||||
// Arrange
|
||||
_compound->Links.setValues({_boxes[0], _boxes[1]});
|
||||
// Act
|
||||
_compound->execute();
|
||||
Part::TopoShape ts = _compound->Shape.getValue();
|
||||
double volume = PartTestHelpers::getVolume(ts.getShape());
|
||||
Base::BoundBox3d bb = ts.getBoundBox();
|
||||
// Assert
|
||||
EXPECT_DOUBLE_EQ(volume, 12.0);
|
||||
EXPECT_TRUE(PartTestHelpers::boxesMatch(bb, Base::BoundBox3d(0.0, 0.0, 0.0, 1.0, 3.0, 3.0)));
|
||||
EXPECT_EQ(ts.countSubShapes(TopAbs_SHAPE), 2);
|
||||
}
|
||||
|
||||
TEST_F(FeatureCompoundTest, testNonIntersecting)
|
||||
{
|
||||
// Arrange
|
||||
_compound->Links.setValues({_boxes[0], _boxes[2]});
|
||||
// Act
|
||||
_compound->execute();
|
||||
Part::TopoShape ts = _compound->Shape.getValue();
|
||||
double volume = PartTestHelpers::getVolume(ts.getShape());
|
||||
Base::BoundBox3d bb = ts.getBoundBox();
|
||||
// Assert
|
||||
EXPECT_DOUBLE_EQ(volume, 12.0);
|
||||
EXPECT_TRUE(PartTestHelpers::boxesMatch(bb, Base::BoundBox3d(0.0, 0.0, 0.0, 1.0, 5.0, 3.0)));
|
||||
EXPECT_EQ(ts.countSubShapes(TopAbs_SHAPE), 2);
|
||||
}
|
||||
Reference in New Issue
Block a user