Skip to content

Commit

Permalink
Prevent crash in unit tests (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
alxbilger authored Nov 14, 2024
1 parent cac8376 commit 0bb37c2
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Tests/forcefield/BeamHookeLawForceFieldTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ struct BeamHookeLawForceFieldTest : public testing::NumericTest<> {
typedef typename DataTypes::Coord Coord;
typedef typename Coord::value_type Real;

BeamHookeLawForceFieldTest()
{
root = sofa::simpleapi::createRootNode(sofa::simulation::getSimulation(), "root");

createObject(root, "DefaultAnimationLoop");
createObject(root, "DefaultVisualManagerLoop");
}



typedef sofa::component::forcefield::BeamHookeLawForceField<DataTypes> TheBeamHookeLawForceField;
Expand Down Expand Up @@ -109,6 +117,7 @@ struct BeamHookeLawForceFieldTest : public testing::NumericTest<> {
template<>
void BeamHookeLawForceFieldTest<defaulttype::Vec3Types>::testFonctionnel() {
EXPECT_MSG_NOEMIT(Error, Warning) ;
ASSERT_NE(root, nullptr);
createObject(root, "MechanicalObject", {{"position", "-1 0 1 1 0 1 -1 0 -1 1 0 -1 0 0 1 0 0 -1 -1 0 0 1 0 0 0 0 0"}});
createObject(root, "TriangleSetTopologyContainer", {{"triangles", "7 5 8 8 2 6 4 6 0 1 8 4 7 3 5 8 5 2 4 8 6 1 7 8"}});

Expand All @@ -118,7 +127,7 @@ void BeamHookeLawForceFieldTest<defaulttype::Vec3Types>::testFonctionnel() {
{"lengthY", "35e-5"},
{"lengthZ", "1374e-5"},
{"radius", "0.25"},
{"varianteSections", "true"}}).get()
{"variantSections", "true"}}).get()
);

EXPECT_NE(traction, nullptr);
Expand Down Expand Up @@ -161,7 +170,7 @@ void BeamHookeLawForceFieldTest<defaulttype::Vec3Types>::basicAttributesTest(){
/// This list needs to be updated if you add an attribute.
sofa::type::vector<std::string> attrnames = {
"crossSectionShape","youngModulus","poissonRatio","length", "radius",
"innerRadius", "lengthY", "lengthZ", "varianteSections", "youngModululsList", "poissonRatioList"
"innerRadius", "lengthY", "lengthZ", "variantSections", "youngModulusList", "poissonRatioList"
};

for(auto& attrname : attrnames)
Expand Down

0 comments on commit 0bb37c2

Please sign in to comment.