Test: Add test for MeasureDistance with two circles
This commit is contained in:
@@ -96,6 +96,9 @@ endif(BUILD_ASSEMBLY)
|
||||
if(BUILD_MATERIAL)
|
||||
list (APPEND TestExecutables Material_tests_run)
|
||||
endif(BUILD_MATERIAL)
|
||||
if(BUILD_MEASURE)
|
||||
list (APPEND TestExecutables Measure_tests_run)
|
||||
endif(BUILD_MEASURE)
|
||||
if(BUILD_MESH)
|
||||
list (APPEND TestExecutables Mesh_tests_run)
|
||||
endif(BUILD_MESH)
|
||||
|
||||
@@ -4,6 +4,9 @@ endif(BUILD_ASSEMBLY)
|
||||
if(BUILD_MATERIAL)
|
||||
add_subdirectory(Material)
|
||||
endif(BUILD_MATERIAL)
|
||||
if(BUILD_MEASURE)
|
||||
add_subdirectory(Measure)
|
||||
endif(BUILD_MEASURE)
|
||||
if(BUILD_MESH)
|
||||
add_subdirectory(Mesh)
|
||||
endif(BUILD_MESH)
|
||||
|
||||
11
tests/src/Mod/Measure/App/CMakeLists.txt
Normal file
11
tests/src/Mod/Measure/App/CMakeLists.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
target_sources(
|
||||
Measure_tests_run
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/MeasureDistance.cpp
|
||||
)
|
||||
|
||||
target_include_directories(
|
||||
Measure_tests_run
|
||||
PUBLIC
|
||||
${CMAKE_BINARY_DIR}
|
||||
)
|
||||
70
tests/src/Mod/Measure/App/MeasureDistance.cpp
Normal file
70
tests/src/Mod/Measure/App/MeasureDistance.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
#include <src/App/InitApplication.h>
|
||||
#include <App/Document.h>
|
||||
#include <Mod/Measure/App/MeasureDistance.h>
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <BRepBuilderAPI_MakeEdge.hxx>
|
||||
#include <gp_Circ.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Wire.hxx>
|
||||
|
||||
class MeasureDistance: public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
static void SetUpTestSuite()
|
||||
{
|
||||
tests::initApplication();
|
||||
}
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
document = App::GetApplication().newDocument("Measure");
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
App::GetApplication().closeDocument(document->getName());
|
||||
}
|
||||
|
||||
App::Document* getDocument() const
|
||||
{
|
||||
return document;
|
||||
}
|
||||
|
||||
TopoDS_Edge makeCircle(const gp_Pnt& pnt) const
|
||||
{
|
||||
gp_Circ circle;
|
||||
circle.SetLocation(pnt);
|
||||
circle.SetRadius(1.0);
|
||||
BRepBuilderAPI_MakeEdge mkEdge(circle);
|
||||
return mkEdge.Edge();
|
||||
}
|
||||
|
||||
private:
|
||||
App::Document* document {};
|
||||
};
|
||||
|
||||
// NOLINTBEGIN
|
||||
TEST_F(MeasureDistance, testCircleCircle)
|
||||
{
|
||||
App::Document* doc = getDocument();
|
||||
auto p1 = dynamic_cast<Part::Feature*>(doc->addObject("Part::Feature", "Shape1"));
|
||||
p1->Shape.setValue(makeCircle(gp_Pnt(0.0, 0.0, 0.0)));
|
||||
auto p2 = dynamic_cast<Part::Feature*>(doc->addObject("Part::Feature", "Shape2"));
|
||||
p2->Shape.setValue(makeCircle(gp_Pnt(3.0, 4.0, 0.0)));
|
||||
|
||||
auto md = dynamic_cast<Measure::MeasureDistance*>(
|
||||
doc->addObject("Measure::MeasureDistance", "Distance"));
|
||||
md->Element1.setValue(p1, {"Edge1"});
|
||||
md->Element2.setValue(p2, {"Edge1"});
|
||||
|
||||
doc->recompute();
|
||||
|
||||
EXPECT_DOUBLE_EQ(md->Distance.getValue(), 5.0);
|
||||
EXPECT_DOUBLE_EQ(md->DistanceX.getValue(), 3.0);
|
||||
EXPECT_DOUBLE_EQ(md->DistanceY.getValue(), 4.0);
|
||||
EXPECT_DOUBLE_EQ(md->DistanceZ.getValue(), 0.0);
|
||||
EXPECT_EQ(md->Position1.getValue(), Base::Vector3d(0.0, 0.0, 0.0));
|
||||
EXPECT_EQ(md->Position2.getValue(), Base::Vector3d(3.0, 4.0, 0.0));
|
||||
}
|
||||
// NOLINTEND
|
||||
17
tests/src/Mod/Measure/CMakeLists.txt
Normal file
17
tests/src/Mod/Measure/CMakeLists.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
target_include_directories(Measure_tests_run PUBLIC
|
||||
${EIGEN3_INCLUDE_DIR}
|
||||
${OCC_INCLUDE_DIR}
|
||||
${Python3_INCLUDE_DIRS}
|
||||
${SMESH_INCLUDE_DIR}
|
||||
${VTK_INCLUDE_DIRS}
|
||||
${XercesC_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
target_link_libraries(Measure_tests_run
|
||||
gtest_main
|
||||
${Google_Tests_LIBS}
|
||||
Measure
|
||||
)
|
||||
|
||||
add_subdirectory(App)
|
||||
Reference in New Issue
Block a user