From 4fae9f10ac50903c84e7771ac606171819cb21cc Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Mon, 21 Oct 2024 14:28:10 +0200 Subject: [PATCH] Prevent crash in unit tests --- Tests/forcefield/BeamHookeLawForceFieldTest.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Tests/forcefield/BeamHookeLawForceFieldTest.cpp b/Tests/forcefield/BeamHookeLawForceFieldTest.cpp index 02a84f87..f9797302 100644 --- a/Tests/forcefield/BeamHookeLawForceFieldTest.cpp +++ b/Tests/forcefield/BeamHookeLawForceFieldTest.cpp @@ -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 TheBeamHookeLawForceField; @@ -109,6 +117,7 @@ struct BeamHookeLawForceFieldTest : public testing::NumericTest<> { template<> void BeamHookeLawForceFieldTest::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"}}); @@ -118,7 +127,7 @@ void BeamHookeLawForceFieldTest::testFonctionnel() { {"lengthY", "35e-5"}, {"lengthZ", "1374e-5"}, {"radius", "0.25"}, - {"varianteSections", "true"}}).get() + {"variantSections", "true"}}).get() ); EXPECT_NE(traction, nullptr); @@ -161,7 +170,7 @@ void BeamHookeLawForceFieldTest::basicAttributesTest(){ /// This list needs to be updated if you add an attribute. sofa::type::vector attrnames = { "crossSectionShape","youngModulus","poissonRatio","length", "radius", - "innerRadius", "lengthY", "lengthZ", "varianteSections", "youngModululsList", "poissonRatioList" + "innerRadius", "lengthY", "lengthZ", "variantSections", "youngModulusList", "poissonRatioList" }; for(auto& attrname : attrnames)