Skip to content

Commit

Permalink
[tests] Template method design pattern from BaseTest in derived class…
Browse files Browse the repository at this point in the history
…es (#5162)

* [tests] Template method design pattern from BaseTest in derived classes

* rename

* use the deprecated function

* Make SetUp and TearDown final

* fix SofaCarving test

* missing override
  • Loading branch information
alxbilger authored Jan 22, 2025
1 parent 41bac37 commit f8ed001
Show file tree
Hide file tree
Showing 83 changed files with 172 additions and 152 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ class TestCollisionPipeline : public BaseSimulationTest {
void checkCollisionPipelineWithMissingContactManager();
int checkCollisionPipelineWithMonkeyValueForDepth(int value);

void SetUp() override
void doSetUp() override
{
sofa::simpleapi::importPlugin(Sofa.Component.StateContainer);
sofa::simpleapi::importPlugin(Sofa.Component.Collision);
}

void TearDown() override
void doTearDown() override
{
if (root)
sofa::simulation::node::unload(root);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ namespace
{

struct TestLocalMinDistance : public BaseSimulationTest {
void SetUp() override
void doSetUp() override
{
sofa::simpleapi::importPlugin(Sofa.Component.StateContainer);
sofa::simpleapi::importPlugin(Sofa.Component.Collision.Detection.Intersection);
}
void TearDown() override
void doTearDown() override
{
}

Expand Down
4 changes: 2 additions & 2 deletions Sofa/Component/Collision/Geometry/tests/Sphere_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ namespace sofa {

struct TestSphere : public BaseSimulationTest
{
void SetUp() override
void doSetUp() override
{
sofa::simpleapi::importPlugin(Sofa.Component.StateContainer);
sofa::simpleapi::importPlugin(Sofa.Component.Collision.Geometry);
Expand All @@ -79,7 +79,7 @@ struct TestSphere : public BaseSimulationTest
m_proxIntersection->setAlarmDistance(1.0);
m_proxIntersection->setContactDistance(1.0);
}
void TearDown() override
void doTearDown() override
{
}

Expand Down
4 changes: 2 additions & 2 deletions Sofa/Component/Collision/Geometry/tests/Triangle_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ namespace sofa
{
struct TestTriangle : public BaseTest
{
void SetUp() override
void doSetUp() override
{
}
void TearDown() override
void doTearDown() override
{

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ struct AffineMovementProjectiveConstraint_test : public BaseSimulationTest, Nume
sofa::helper::RandomGenerator randomGenerator;

// Create the context for the scene
void SetUp() override
void doSetUp() override
{
// Init simulation
simulation = sofa::simulation::getSimulation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ struct DirectionProjectiveConstraint_test : public BaseSimulationTest, NumericTe
typename MechanicalObject::SPtr dofs;

/// Create the context for the tests.
void SetUp() override
void doSetUp() override
{
//Init
simulation = sofa::simulation::getSimulation();
Expand Down Expand Up @@ -219,7 +219,7 @@ struct DirectionProjectiveConstraint_test : public BaseSimulationTest, NumericTe
return succeed;
}

void TearDown() override
void doTearDown() override
{
if (root!=nullptr)
sofa::simulation::node::unload(root);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ struct LineProjectiveConstraint_test : public BaseSimulationTest, NumericTest<ty
typename MechanicalObject::SPtr dofs;

/// Create the context for the tests.
void SetUp() override
void doSetUp() override
{
simulation = sofa::simulation::getSimulation();
ASSERT_NE(simulation, nullptr);
Expand Down Expand Up @@ -204,7 +204,7 @@ const PointSetTopologyContainer::SPtr topology = core::objectmodel::New<PointSet
return succeed;
}

void TearDown() override
void doTearDown() override
{
if (root!=nullptr)
sofa::simulation::node::unload(root);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ struct PlaneProjectiveConstraint_test : public BaseSimulationTest, NumericTest<t
typename MechanicalObject::SPtr dofs;

/// Create the context for the matrix tests.
void SetUp() override
void doSetUp() override
{
simulation = sofa::simulation::getSimulation();
ASSERT_NE(simulation, nullptr);
Expand Down Expand Up @@ -203,7 +203,7 @@ const PointSetTopologyContainer::SPtr topology = core::objectmodel::New<PointSet
return succeed;
}

void TearDown() override
void doTearDown() override
{
if (root!=nullptr)
sofa::simulation::node::unload(root);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ struct PointProjectiveConstraint_test : public BaseSimulationTest, NumericTest<t
typename MechanicalObject::SPtr dofs;

/// Create the context for the tests.
void SetUp() override
void doSetUp() override
{
simulation = sofa::simulation::getSimulation();
ASSERT_NE(simulation, nullptr);
Expand Down Expand Up @@ -207,7 +207,7 @@ struct PointProjectiveConstraint_test : public BaseSimulationTest, NumericTest<t
return succeed;
}

void TearDown() override
void doTearDown() override
{
if (root!=nullptr)
sofa::simulation::node::unload(root);
Expand Down
2 changes: 1 addition & 1 deletion Sofa/Component/Engine/Analyze/tests/AverageCoord_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ struct AverageCoord_test : public BaseSimulationTest,
typename MechanicalObject<DataTypes>::SPtr m_mecaobject;


void SetUp() override
void doSetUp() override
{
m_simu = sofa::simulation::getSimulation();
ASSERT_NE(m_simu, nullptr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ struct ClusteringEngine_test : public BaseSimulationTest,
typename MechanicalObject<DataTypes>::SPtr m_mecaobject;


void SetUp() override
void doSetUp() override
{
m_simu = sofa::simulation::getSimulation();
ASSERT_NE(m_simu, nullptr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct ExtrudeEdgesAndGenerateQuads_test : public BaseSimulationTest,
Node::SPtr m_node;
typename ThisClass::SPtr m_thisObject;

void SetUp() override
void doSetUp() override
{
m_simu = sofa::simulation::getSimulation();
ASSERT_NE(m_simu, nullptr);
Expand Down
2 changes: 1 addition & 1 deletion Sofa/Component/Engine/Generate/tests/MergePoints_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct MergePoints_test : public BaseSimulationTest,
Simulation* m_simu;
typename ThisClass::SPtr m_thisObject;

void SetUp() override
void doSetUp() override
{
m_simu = sofa::simulation::getSimulation();
ASSERT_NE(m_simu, nullptr);
Expand Down
4 changes: 2 additions & 2 deletions Sofa/Component/Engine/Select/tests/BoxROI_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ struct BoxROITest : public sofa::testing::BaseTest
Node::SPtr m_node;
typename TheBoxROI::SPtr m_boxroi;

void onSetUp() override
void doSetUp() override
{
this->loadPlugins({
Sofa.Component.StateContainer,
Expand All @@ -87,7 +87,7 @@ struct BoxROITest : public sofa::testing::BaseTest
m_node->addObject(m_boxroi);
}

void onTearDown() override
void doTearDown() override
{
if (m_root != nullptr){
sofa::simulation::node::unload(m_root);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct ComplementaryROI_test : public BaseSimulationTest,
typename ThisClass::SPtr m_thisObject;


void SetUp() override
void doSetUp() override
{
m_simu = sofa::simulation::getSimulation();
ASSERT_NE(m_simu, nullptr);
Expand Down
4 changes: 2 additions & 2 deletions Sofa/Component/Engine/Select/tests/MeshROI_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct MeshROI_test : public BaseSimulationTest,
Node::SPtr m_root;
ThisClass* m_thisObject;

void SetUp() override
void doSetUp() override
{
simpleapi::importPlugin(Sofa.Component.Engine.Select);
simpleapi::importPlugin(Sofa.Component.Topology.Container.Constant);
Expand All @@ -86,7 +86,7 @@ struct MeshROI_test : public BaseSimulationTest,
ASSERT_NE(m_thisObject, nullptr) ;
}

void TearDown() override
void doTearDown() override
{
sofa::simulation::node::unload(m_root) ;
}
Expand Down
4 changes: 2 additions & 2 deletions Sofa/Component/Engine/Select/tests/MeshSubsetEngine_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct MeshSubsetEngine_test : public testing::BaseSimulationTest
sofa::simulation::Node::SPtr m_root;
typename component::engine::select::MeshSubsetEngine<_DataTypes>::SPtr m_engine;

void SetUp() override
void doSetUp() override
{
simpleapi::importPlugin(Sofa.Component.Engine.Select);

Expand All @@ -44,7 +44,7 @@ struct MeshSubsetEngine_test : public testing::BaseSimulationTest
m_root->addObject(m_engine);
}

void TearDown() override
void doTearDown() override
{
sofa::simulation::node::unload(m_root) ;
}
Expand Down
2 changes: 1 addition & 1 deletion Sofa/Component/Engine/Select/tests/PlaneROI_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct PlaneROI_test : public BaseSimulationTest,
Node::SPtr m_node1, m_node2;
typename ThisClass::SPtr m_thisObject;

void SetUp() override
void doSetUp() override
{
// SetUp1
m_simu = sofa::simulation::getSimulation();
Expand Down
2 changes: 1 addition & 1 deletion Sofa/Component/Engine/Select/tests/SphereROI_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct SphereROI_test : public BaseSimulationTest,
Node::SPtr m_node;
typename ThisClass::SPtr m_thisObject;

void SetUp() override
void doSetUp() override
{
m_simu = sofa::simulation::getSimulation();
ASSERT_NE(m_simu, nullptr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct DifferenceEngine_test : public BaseSimulationTest,
Node::SPtr m_node;
typename ThisClass::SPtr m_thisObject;

void SetUp() override
void doSetUp() override
{
m_simu = sofa::simulation::getSimulation();
ASSERT_NE(m_simu, nullptr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct DilateEngine_test : public BaseSimulationTest,
Node::SPtr m_node;
typename ThisClass::SPtr m_thisObject;

void SetUp() override
void doSetUp() override
{
m_simu = sofa::simulation::getSimulation();
ASSERT_NE(m_simu, nullptr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct SmoothMeshEngine_test : public BaseSimulationTest,
Node::SPtr m_node;
typename ThisClass::SPtr m_thisObject;

void SetUp() override
void doSetUp() override
{
m_simu = sofa::simulation::getSimulation();
ASSERT_NE(m_simu, nullptr);
Expand Down
4 changes: 2 additions & 2 deletions Sofa/Component/IO/Mesh/tests/MeshExporter_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ class MeshExporter_test
/// remove the file created...
std::vector<string> dataPath;

void SetUp() override
void doSetUp() override
{
sofa::simpleapi::importPlugin(Sofa.Component.StateContainer);
sofa::simpleapi::importPlugin(Sofa.Component.Topology.Container.Grid);
}

void TearDown() override
void doTearDown() override
{
for (const auto& pathToRemove : dataPath)
{
Expand Down
2 changes: 1 addition & 1 deletion Sofa/Component/IO/Mesh/tests/MeshGmshLoader_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace meshgmshloader_test
/**
* Constructor call for each test
*/
void SetUp() override {}
void doSetUp() override {}

/**
* Helper function to check mesh loading.
Expand Down
4 changes: 2 additions & 2 deletions Sofa/Component/IO/Mesh/tests/STLExporter_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ class STLExporter_test : public BaseSimulationTest {
/// remove the file created...
std::vector<std::string> dataPath ;

void SetUp() override
void doSetUp() override
{
sofa::simpleapi::importPlugin(Sofa.Component.StateContainer);
sofa::simpleapi::importPlugin(Sofa.Component.Visual);
sofa::simpleapi::importPlugin(Sofa.Component.IO.Mesh);
}

void TearDown() override
void doTearDown() override
{
for (const auto& pathToRemove : dataPath)
{
Expand Down
4 changes: 2 additions & 2 deletions Sofa/Component/IO/Mesh/tests/VisualModelOBJExporter_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ class VisualModelOBJExporter_test : public BaseSimulationTest {
/// remove the file created...
std::vector<std::string> dataPath ;

void SetUp() override
void doSetUp() override
{
}

void TearDown() override
void doTearDown() override
{
for (const auto& pathToRemove : dataPath)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ struct BarycentricMapperTriangleSetTopologyTest : public BaseTest, public Baryc
typename Out::VecCoord m_out;
TriangleSetTopologyContainer::SPtr m_topology;

void SetUp() override
void doSetUp() override
{
m_in.push_back(Vec3(0.5, 1.5, 0.0));
m_in.push_back(Vec3(1.5, 0.0, 2.5));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ struct RigidMappingTest : public sofa::mapping_test::Mapping_test<_RigidMapping>
typedef typename OutMechanicalObject::ReadVecCoord ReadOutVecCoord;
typedef typename OutMechanicalObject::ReadVecDeriv ReadOutVecDeriv;

void SetUp() override
void doSetUp() override
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ struct SquareDistanceMappingCompare_test : NumericTest<SReal>
simulation::Node::SPtr oneMapping;
simulation::Node::SPtr twoMappings;

void onSetUp() override
void doSetUp() override
{
root = simulation::getSimulation()->createNewNode("root");

Expand Down
4 changes: 2 additions & 2 deletions Sofa/Component/Mass/tests/DiagonalMass_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class DiagonalMass_test : public BaseTest
typename MechanicalObject<DataTypes>::SPtr mstate;
typename DiagonalMass<DataTypes>::SPtr mass;

void SetUp() override
void doSetUp() override
{
sofa::simpleapi::importPlugin(Sofa.Component.Topology.Container.Dynamic);
sofa::simpleapi::importPlugin(Sofa.Component.Topology.Container.Grid);
Expand All @@ -107,7 +107,7 @@ class DiagonalMass_test : public BaseTest
root = simulation::getSimulation()->createNewGraph("root");
}

void TearDown() override
void doTearDown() override
{
if (root!=nullptr)
sofa::simulation::node::unload(root);
Expand Down
Loading

0 comments on commit f8ed001

Please sign in to comment.