From 4b7cf85ac66cbebf0ac7acb9516f646d7a084c7d Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Tue, 21 Jan 2025 12:42:49 +0100 Subject: [PATCH 1/6] [StateContainer] Extensive tests of MechanicalObject::vOp --- .../StateContainer/tests/CMakeLists.txt | 1 + .../tests/MechanicalObjectVOp_test.cpp | 798 ++++++++++++++++++ 2 files changed, 799 insertions(+) create mode 100644 Sofa/Component/StateContainer/tests/MechanicalObjectVOp_test.cpp diff --git a/Sofa/Component/StateContainer/tests/CMakeLists.txt b/Sofa/Component/StateContainer/tests/CMakeLists.txt index 14059938bf1..970fa4e6382 100644 --- a/Sofa/Component/StateContainer/tests/CMakeLists.txt +++ b/Sofa/Component/StateContainer/tests/CMakeLists.txt @@ -4,6 +4,7 @@ project(Sofa.Component.StateContainer_test) set(SOURCE_FILES MechanicalObject_test.cpp + MechanicalObjectVOp_test.cpp ) add_executable(${PROJECT_NAME} ${SOURCE_FILES}) diff --git a/Sofa/Component/StateContainer/tests/MechanicalObjectVOp_test.cpp b/Sofa/Component/StateContainer/tests/MechanicalObjectVOp_test.cpp new file mode 100644 index 00000000000..191b594e589 --- /dev/null +++ b/Sofa/Component/StateContainer/tests/MechanicalObjectVOp_test.cpp @@ -0,0 +1,798 @@ +/****************************************************************************** +* SOFA, Simulation Open-Framework Architecture * +* (c) 2006 INRIA, USTL, UJF, CNRS, MGH * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU Lesser General Public License as published by * +* the Free Software Foundation; either version 2.1 of the License, or (at * +* your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but WITHOUT * +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * +* for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with this program. If not, see . * +******************************************************************************* +* Authors: The SOFA Team and external contributors (see Authors.txt) * +* * +* Contact information: contact@sofa-framework.org * +******************************************************************************/ +#include +#include + +namespace sofa +{ + +template +struct MechanicalObjectVOpTest : public testing::BaseTest +{ + using MO = component::statecontainer::MechanicalObject; + + void onSetUp() override + { + m_mechanicalObject = core::objectmodel::New(); + + m_mechanicalObject->x0.forceSet(); + m_mechanicalObject->f.forceSet(); + m_mechanicalObject->xfree.forceSet(); + m_mechanicalObject->vfree.forceSet(); + + m_mechanicalObject->resize(10); + + setVecValues(1); + checkVecValues(1); + + setVecValues(2); + checkVecValues(2); + + setVecValues(5); + checkVecValues(5); + + setVecValues(1); + checkVecValues(1); + + setVecValues(3); + checkVecValues(3); + + setVecValues(8); + checkVecValues(8); + } + + template + void setVecValues(Real_t coefficient = 1) const + { + unsigned int index {}; + auto vec = sofa::helper::getWriteOnlyAccessor(*m_mechanicalObject->write(vtype)); + ASSERT_EQ(vec.size(), 10); + for (auto& v : vec) + { + for (std::size_t i = 0; i < v.size(); ++i) + { + v[i] = static_cast>(index) * coefficient; + } + ++index; + } + } + + template + void checkVecValues(Real_t coefficient = 1) const + { + unsigned int index {}; + auto vec = sofa::helper::getReadAccessor(*m_mechanicalObject->read(vtype)); + ASSERT_EQ(vec.size(), 10); + for (auto& v : vec) + { + for (std::size_t i = 0; i < v.size(); ++i) + { + EXPECT_FLOATINGPOINT_EQ(v[i], static_cast>(index) * coefficient); + } + ++index; + } + } + + template + void checkVecSpatialValues(Real_t coefficient = 1) const + { + unsigned int index {}; + auto vec = sofa::helper::getReadAccessor(*m_mechanicalObject->read(vtype)); + ASSERT_EQ(vec.size(), 10); + for (auto& v : vec) + { + for (std::size_t i = 0; i < DataTypes::spatial_dimensions; ++i) + { + EXPECT_FLOATINGPOINT_EQ(v[i], static_cast>(index) * coefficient); + } + ++index; + } + } + + bool v_null() const + { + //check that an error is emitted + { + EXPECT_MSG_EMIT(Error); + m_mechanicalObject->vOp(nullptr, core::VecId::null()); + } + + checkVecValues(1); + checkVecValues(1); + + return true; + } + + void resetPosition() const + { + //check that an error is not emitted + { + EXPECT_MSG_NOEMIT(Error); + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position); + } + + //position is reset + for (auto& position : m_mechanicalObject->readPositions()) + { + static Coord_t defaulConstructedCoord; + for (std::size_t i = 0; i < position.size(); ++i) + { + EXPECT_FLOATINGPOINT_EQ(position[i], defaulConstructedCoord[i]); + } + } + + checkVecValues(1); + } + + void resetVelocity() const + { + //check that an error is not emitted + { + EXPECT_MSG_NOEMIT(Error); + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity); + } + + //velocity is reset + for (auto& velocity : m_mechanicalObject->readVelocities()) + { + static Deriv_t defaulConstructedDeriv; + for (std::size_t i = 0; i < velocity.size(); ++i) + { + EXPECT_FLOATINGPOINT_EQ(velocity[i], defaulConstructedDeriv[i]); + } + } + + checkVecValues(1); + } + + void multiplyByScalarPosition() const + { + { + EXPECT_MSG_NOEMIT(Error); + //v *= f + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::ConstVecId::null(), core::vec_id::read_access::position, 2._sreal); + } + checkVecSpatialValues(2); + checkVecValues(1); + } + + void multiplyByScalarVelocity() const + { + { + EXPECT_MSG_NOEMIT(Error); + //v *= f + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::ConstVecId::null(), core::vec_id::read_access::velocity, 2._sreal); + } + checkVecValues(1); + checkVecValues(2); + } + + void equalOtherMultiplyByScalarPosition() const + { + { + EXPECT_MSG_NOEMIT(Error); + //v = b*f + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::ConstVecId::null(), core::vec_id::read_access::restPosition, 2._sreal); + } + checkVecSpatialValues(4); + checkVecValues(1); + } + + void equalOtherMultiplyByScalarVelocity() const + { + { + EXPECT_MSG_NOEMIT(Error); + //v = b*f + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::ConstVecId::null(), core::vec_id::read_access::force, 2._sreal); + } + checkVecValues(1); + checkVecValues(6); + } + + void equalOtherMultiplyByScalarPositionMix() const + { + { + EXPECT_MSG_EMIT(Error); + //v = b*f + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::ConstVecId::null(), core::vec_id::read_access::velocity, 2._sreal); + } + checkVecSpatialValues(1); + checkVecValues(1); + } + + void equalOtherMultiplyByScalarVelocityMix() const + { + { + EXPECT_MSG_EMIT(Error); + //v = b*f + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::ConstVecId::null(), core::vec_id::read_access::position, 2._sreal); + } + checkVecSpatialValues(1); + checkVecValues(2); + } + + void equalOtherPosition() const + { + { + EXPECT_MSG_NOEMIT(Error); + //v = a + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::vec_id::read_access::restPosition, core::ConstVecId::null(), 1._sreal); + } + checkVecValues(2); + checkVecValues(1); + } + + void equalOtherPositionMix() const + { + { + EXPECT_MSG_EMIT(Error); + //v = a + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::vec_id::read_access::velocity, core::ConstVecId::null(), 1._sreal); + } + checkVecValues(1); + checkVecValues(1); + } + + void equalOtherVelocity() const + { + { + EXPECT_MSG_NOEMIT(Error); + //v = a + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::vec_id::read_access::force, core::ConstVecId::null(), 1._sreal); + } + checkVecValues(1); + checkVecValues(3); + } + + void equalOtherVelocityMix() const + { + { + EXPECT_MSG_EMIT(Error); + //v = a + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::vec_id::read_access::restPosition, core::ConstVecId::null(), 1._sreal); + } + checkVecValues(1); + checkVecValues(1); + } + + void plusEqualOtherPosition() const + { + { + EXPECT_MSG_NOEMIT(Error); + //v += b + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::vec_id::read_access::position, core::vec_id::read_access::restPosition, 1._sreal); + } + checkVecSpatialValues(3); + checkVecValues(1); + } + + void plusEqualOtherPositionMix() const + { + { + EXPECT_MSG_NOEMIT(Error); + //v += b + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::vec_id::read_access::position, core::vec_id::read_access::freeVelocity, 1._sreal); + } + checkVecSpatialValues(8+1); + checkVecValues(1); + } + + void plusEqualOtherVelocity() const + { + { + EXPECT_MSG_NOEMIT(Error); + //v += b + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::vec_id::read_access::velocity, core::vec_id::read_access::force, 1._sreal); + } + checkVecValues(1); + checkVecValues(4); + } + + void plusEqualOtherVelocityMix() const + { + { + EXPECT_MSG_EMIT(Error); + //v += b + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::vec_id::read_access::velocity, core::vec_id::read_access::position, 1._sreal); + } + checkVecValues(1); + checkVecValues(1); + } + + void plusEqualOtherMultipliedByScalarPosition() const + { + { + EXPECT_MSG_NOEMIT(Error); + //v += b*f + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::vec_id::read_access::position, core::vec_id::read_access::restPosition, 2._sreal); + } + checkVecSpatialValues(5); + checkVecValues(1); + } + + void plusEqualOtherMultipliedByScalarPositionMix() const + { + { + EXPECT_MSG_NOEMIT(Error); + //v += b*f + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::vec_id::read_access::position, core::vec_id::read_access::freeVelocity, 2._sreal); + } + checkVecSpatialValues(8*2+1); + checkVecValues(1); + } + + void plusEqualOtherMultipliedByScalarVelocity() const + { + { + EXPECT_MSG_NOEMIT(Error); + //v += b*f + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::vec_id::read_access::velocity, core::vec_id::read_access::force, 2._sreal); + } + checkVecValues(1); + checkVecValues(7); + } + + void plusEqualOtherMultipliedByScalarVelocityMix() const + { + { + EXPECT_MSG_EMIT(Error); + //v += b*f + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::vec_id::read_access::velocity, core::vec_id::read_access::freePosition, 2._sreal); + } + checkVecValues(1); + checkVecValues(1); + } + + void plusEqualOtherPosition_2() const + { + { + EXPECT_MSG_NOEMIT(Error); + //v += a + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::vec_id::read_access::restPosition, core::vec_id::read_access::position, 1._sreal); + } + checkVecSpatialValues(3); + checkVecValues(1); + } + + void plusEqualOtherPositionMix_2() const + { + { + EXPECT_MSG_EMIT(Error); + //v += a + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::vec_id::read_access::freeVelocity, core::vec_id::read_access::position, 1._sreal); + } + checkVecSpatialValues(1); + checkVecValues(1); + } + + void plusEqualOtherVelocity_2() const + { + { + EXPECT_MSG_NOEMIT(Error); + //v += a + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::vec_id::read_access::force, core::vec_id::read_access::velocity, 1._sreal); + } + checkVecValues(1); + checkVecValues(4); + } + + void plusEqualOtherVelocityMix_2() const + { + { + EXPECT_MSG_EMIT(Error); + //v += a + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::vec_id::read_access::freePosition, core::vec_id::read_access::velocity, 1._sreal); + } + checkVecValues(1); + checkVecValues(1); + } + + void multipliedByScalarThenAddOtherPosition() const + { + { + EXPECT_MSG_NOEMIT(Error); + //v = a+v*f + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::vec_id::read_access::restPosition, core::vec_id::read_access::position, 3_sreal); + } + checkVecSpatialValues(5); + checkVecValues(1); + } + + void multipliedByScalarThenAddOtherPositionMix() const + { + { + EXPECT_MSG_EMIT(Error); + //v = a+v*f + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::vec_id::read_access::freeVelocity, core::vec_id::read_access::position, 3_sreal); + } + checkVecSpatialValues(1); + checkVecValues(1); + } + + void multipliedByScalarThenAddOtherVelocity() const + { + { + EXPECT_MSG_NOEMIT(Error); + //v = a+v*f + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::vec_id::read_access::force, core::vec_id::read_access::velocity, 7._sreal); + } + checkVecValues(1); + checkVecValues(10); + } + + void multipliedByScalarThenAddOtherVelocityMix() const + { + { + EXPECT_MSG_EMIT(Error); + //v = a+v*f + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::vec_id::read_access::freePosition, core::vec_id::read_access::velocity, 7._sreal); + } + checkVecValues(1); + checkVecValues(1); + } + + void equalSumPosition() const + { + { + EXPECT_MSG_NOEMIT(Error); + //v = a+b + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::vec_id::read_access::restPosition, core::vec_id::read_access::freePosition, 1_sreal); + } + checkVecSpatialValues(7); + checkVecValues(1); + } + + void equalSumPositionMix1() const + { + { + EXPECT_MSG_NOEMIT(Error); + //v = a+b + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::vec_id::read_access::restPosition, core::vec_id::read_access::freeVelocity, 1_sreal); + } + checkVecSpatialValues(2+8); + checkVecValues(1); + } + + void equalSumPositionMix2() const + { + { + EXPECT_MSG_EMIT(Error); + //v = a+b + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::vec_id::read_access::freeVelocity, core::vec_id::read_access::freePosition, 1_sreal); + } + checkVecSpatialValues(1); + checkVecValues(1); + } + + void equalSumVelocity() const + { + { + EXPECT_MSG_NOEMIT(Error); + //v = a+b + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::vec_id::read_access::force, core::vec_id::read_access::freeVelocity, 1._sreal); + } + checkVecValues(1); + checkVecValues(11); + } + + void equalSumVelocityMix1() const + { + { + EXPECT_MSG_EMIT(Error); + //v = a+b + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::vec_id::read_access::position, core::vec_id::read_access::freeVelocity, 1._sreal); + } + checkVecValues(1); + checkVecValues(1); + } + + void equalSumVelocityMix2() const + { + { + EXPECT_MSG_EMIT(Error); + //v = a+b + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::vec_id::read_access::force, core::vec_id::read_access::position, 1._sreal); + } + checkVecValues(1); + checkVecValues(1); + } + + void equalSumWithScalarPosition() const + { + { + EXPECT_MSG_NOEMIT(Error); + //v = a+b*f + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::vec_id::read_access::restPosition, core::vec_id::read_access::freePosition, 12_sreal); + } + checkVecSpatialValues(5*12 + 2); + checkVecValues(1); + } + + void equalSumWithScalarPositionMix1() const + { + { + EXPECT_MSG_EMIT(Error); + //v = a+b*f + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::vec_id::read_access::velocity, core::vec_id::read_access::freePosition, 12_sreal); + } + checkVecSpatialValues(1); + checkVecValues(1); + } + + void equalSumWithScalarPositionMix2() const + { + { + EXPECT_MSG_NOEMIT(Error); + //v = a+b*f + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::vec_id::read_access::restPosition, core::vec_id::read_access::freeVelocity, 12_sreal); + } + checkVecSpatialValues(8*12+2); + checkVecValues(1); + } + + void equalSumWithScalarVelocity() const + { + { + EXPECT_MSG_NOEMIT(Error); + //v = a+b*f + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::vec_id::read_access::force, core::vec_id::read_access::freeVelocity, 12_sreal); + } + checkVecSpatialValues(1); + checkVecValues(8*12 + 3); + } + + void equalSumWithScalarVelocityMix1() const + { + { + EXPECT_MSG_EMIT(Error); + //v = a+b*f + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::vec_id::read_access::position, core::vec_id::read_access::freeVelocity, 12_sreal); + } + checkVecSpatialValues(1); + checkVecValues(1); + } + + void equalSumWithScalarVelocityMix2() const + { + { + EXPECT_MSG_EMIT(Error); + //v = a+b*f + m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::vec_id::read_access::force, core::vec_id::read_access::position, 12_sreal); + } + checkVecSpatialValues(1); + checkVecValues(1); + } + + typename MO::SPtr m_mechanicalObject; +}; + +typedef ::testing::Types< + defaulttype::Vec1Types, + defaulttype::Vec2Types, + defaulttype::Vec3Types, + defaulttype::Rigid2Types, + defaulttype::Rigid3Types +> DataTypesList; + +TYPED_TEST_SUITE(MechanicalObjectVOpTest, DataTypesList); + +TYPED_TEST(MechanicalObjectVOpTest, v_null) +{ + EXPECT_TRUE(this->v_null()); +} + +TYPED_TEST(MechanicalObjectVOpTest, resetPosition) +{ + this->resetPosition(); +} + +TYPED_TEST(MechanicalObjectVOpTest, multiplyByScalarPosition) +{ + this->multiplyByScalarPosition(); +} + +TYPED_TEST(MechanicalObjectVOpTest, multiplyByScalarVelocity) +{ + this->multiplyByScalarVelocity(); +} + +TYPED_TEST(MechanicalObjectVOpTest, equalOtherMultiplyByScalarPosition) +{ + this->equalOtherMultiplyByScalarPosition(); +} + +TYPED_TEST(MechanicalObjectVOpTest, equalOtherMultiplyByScalarVelocity) +{ + this->equalOtherMultiplyByScalarVelocity(); +} + +TYPED_TEST(MechanicalObjectVOpTest, equalOtherMultiplyByScalarPositionMix) +{ + this->equalOtherMultiplyByScalarPositionMix(); +} + +TYPED_TEST(MechanicalObjectVOpTest, equalOtherMultiplyByScalarVelocityMix) +{ + this->equalOtherMultiplyByScalarPositionMix(); +} + +TYPED_TEST(MechanicalObjectVOpTest, equalOtherPosition) +{ + this->equalOtherPosition(); +} + +TYPED_TEST(MechanicalObjectVOpTest, equalOtherPositionMix) +{ + this->equalOtherPositionMix(); +} + +TYPED_TEST(MechanicalObjectVOpTest, equalOtherVelocity) +{ + this->equalOtherVelocity(); +} + +TYPED_TEST(MechanicalObjectVOpTest, equalOtherVelocityMix) +{ + this->equalOtherVelocityMix(); +} + +TYPED_TEST(MechanicalObjectVOpTest, plusEqualOtherPosition) +{ + this->plusEqualOtherPosition(); +} + +TYPED_TEST(MechanicalObjectVOpTest, plusEqualOtherPositionMix) +{ + this->plusEqualOtherPositionMix(); +} + +TYPED_TEST(MechanicalObjectVOpTest, plusEqualOtherVelocity) +{ + this->plusEqualOtherVelocity(); +} + +TYPED_TEST(MechanicalObjectVOpTest, plusEqualOtherVelocityMix) +{ + this->plusEqualOtherVelocityMix(); +} + +TYPED_TEST(MechanicalObjectVOpTest, plusEqualOtherMultipliedByScalarPosition) +{ + this->plusEqualOtherMultipliedByScalarPosition(); +} + +TYPED_TEST(MechanicalObjectVOpTest, plusEqualOtherMultipliedByScalarPositionMix) +{ + this->plusEqualOtherMultipliedByScalarPositionMix(); +} + +TYPED_TEST(MechanicalObjectVOpTest, plusEqualOtherMultipliedByScalarVelocity) +{ + this->plusEqualOtherMultipliedByScalarVelocity(); +} + +TYPED_TEST(MechanicalObjectVOpTest, plusEqualOtherMultipliedByScalarVelocityMix) +{ + this->plusEqualOtherMultipliedByScalarVelocityMix(); +} + +TYPED_TEST(MechanicalObjectVOpTest, plusEqualOtherPosition_2) +{ + this->plusEqualOtherPosition_2(); +} + +TYPED_TEST(MechanicalObjectVOpTest, plusEqualOtherPositionMix_2) +{ + this->plusEqualOtherPositionMix_2(); +} + +TYPED_TEST(MechanicalObjectVOpTest, plusEqualOtherVelocity_2) +{ + this->plusEqualOtherVelocity_2(); +} + +TYPED_TEST(MechanicalObjectVOpTest, plusEqualOtherVelocityMix_2) +{ + this->plusEqualOtherVelocityMix_2(); +} + +TYPED_TEST(MechanicalObjectVOpTest, multipliedByScalarThenAddOtherPosition) +{ + this->multipliedByScalarThenAddOtherPosition(); +} + +TYPED_TEST(MechanicalObjectVOpTest, multipliedByScalarThenAddOtherPositionMix) +{ + this->multipliedByScalarThenAddOtherPositionMix(); +} + +TYPED_TEST(MechanicalObjectVOpTest, multipliedByScalarThenAddOtherVelocity) +{ + this->multipliedByScalarThenAddOtherVelocity(); +} + +TYPED_TEST(MechanicalObjectVOpTest, multipliedByScalarThenAddOtherVelocityMix) +{ + this->multipliedByScalarThenAddOtherVelocityMix(); +} + +TYPED_TEST(MechanicalObjectVOpTest, equalSumPosition) +{ + this->equalSumPosition(); +} + +TYPED_TEST(MechanicalObjectVOpTest, equalSumPositionMix1) +{ + this->equalSumPositionMix1(); +} + +TYPED_TEST(MechanicalObjectVOpTest, equalSumPositionMix2) +{ + this->equalSumPositionMix2(); +} + +TYPED_TEST(MechanicalObjectVOpTest, equalSumVelocity) +{ + this->equalSumVelocity(); +} + +TYPED_TEST(MechanicalObjectVOpTest, equalSumVelocityMix1) +{ + this->equalSumVelocityMix1(); +} + +TYPED_TEST(MechanicalObjectVOpTest, equalSumVelocityMix2) +{ + this->equalSumVelocityMix2(); +} + +TYPED_TEST(MechanicalObjectVOpTest, equalSumWithScalarPosition) +{ + this->equalSumWithScalarPosition(); +} + +TYPED_TEST(MechanicalObjectVOpTest, equalSumWithScalarPositionMix1) +{ + this->equalSumWithScalarPositionMix1(); +} + +TYPED_TEST(MechanicalObjectVOpTest, equalSumWithScalarPositionMix2) +{ + this->equalSumWithScalarPositionMix2(); +} + +TYPED_TEST(MechanicalObjectVOpTest, equalSumWithScalarVelocity) +{ + this->equalSumWithScalarVelocity(); +} + +TYPED_TEST(MechanicalObjectVOpTest, equalSumWithScalarVelocityMix1) +{ + this->equalSumWithScalarVelocityMix1(); +} + +TYPED_TEST(MechanicalObjectVOpTest, equalSumWithScalarVelocityMix2) +{ + this->equalSumWithScalarVelocityMix2(); +} + +} \ No newline at end of file From a7836ecb6225e088d2570edac1148feefc49490f Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Tue, 21 Jan 2025 15:45:46 +0100 Subject: [PATCH 2/6] fix wrong name --- .../Component/StateContainer/tests/MechanicalObjectVOp_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sofa/Component/StateContainer/tests/MechanicalObjectVOp_test.cpp b/Sofa/Component/StateContainer/tests/MechanicalObjectVOp_test.cpp index 191b594e589..40b744d8109 100644 --- a/Sofa/Component/StateContainer/tests/MechanicalObjectVOp_test.cpp +++ b/Sofa/Component/StateContainer/tests/MechanicalObjectVOp_test.cpp @@ -632,7 +632,7 @@ TYPED_TEST(MechanicalObjectVOpTest, equalOtherMultiplyByScalarPositionMix) TYPED_TEST(MechanicalObjectVOpTest, equalOtherMultiplyByScalarVelocityMix) { - this->equalOtherMultiplyByScalarPositionMix(); + this->equalOtherMultiplyByScalarVelocityMix(); } TYPED_TEST(MechanicalObjectVOpTest, equalOtherPosition) From df4ffac6a8ca749ef0344769ec3d6adae8edf296 Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Wed, 22 Jan 2025 09:31:30 +0100 Subject: [PATCH 3/6] fix test --- .../Component/StateContainer/tests/MechanicalObjectVOp_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sofa/Component/StateContainer/tests/MechanicalObjectVOp_test.cpp b/Sofa/Component/StateContainer/tests/MechanicalObjectVOp_test.cpp index 40b744d8109..6f3ca10c95e 100644 --- a/Sofa/Component/StateContainer/tests/MechanicalObjectVOp_test.cpp +++ b/Sofa/Component/StateContainer/tests/MechanicalObjectVOp_test.cpp @@ -227,7 +227,7 @@ struct MechanicalObjectVOpTest : public testing::BaseTest m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::ConstVecId::null(), core::vec_id::read_access::position, 2._sreal); } checkVecSpatialValues(1); - checkVecValues(2); + checkVecValues(1); } void equalOtherPosition() const From f0c884e09d7e13b7245c347bc6a28c4e24c15644 Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Wed, 22 Jan 2025 10:30:25 +0100 Subject: [PATCH 4/6] Use variable for the coefficients --- .../tests/MechanicalObjectVOp_test.cpp | 196 ++++++++++-------- 1 file changed, 104 insertions(+), 92 deletions(-) diff --git a/Sofa/Component/StateContainer/tests/MechanicalObjectVOp_test.cpp b/Sofa/Component/StateContainer/tests/MechanicalObjectVOp_test.cpp index 6f3ca10c95e..b1ca88edc2a 100644 --- a/Sofa/Component/StateContainer/tests/MechanicalObjectVOp_test.cpp +++ b/Sofa/Component/StateContainer/tests/MechanicalObjectVOp_test.cpp @@ -29,6 +29,13 @@ template struct MechanicalObjectVOpTest : public testing::BaseTest { using MO = component::statecontainer::MechanicalObject; + + static constexpr Real_t positionCoefficient = 19; + static constexpr Real_t restPositionCoefficient = 20; + static constexpr Real_t freePositionCoefficient = 5; + static constexpr Real_t velocityCoefficient = 12; + static constexpr Real_t forceCoefficient = 63; + static constexpr Real_t freeVelocityCoefficient = 78; void onSetUp() override { @@ -41,23 +48,23 @@ struct MechanicalObjectVOpTest : public testing::BaseTest m_mechanicalObject->resize(10); - setVecValues(1); - checkVecValues(1); + setVecValues(positionCoefficient); + checkVecValues(positionCoefficient); - setVecValues(2); - checkVecValues(2); + setVecValues(restPositionCoefficient); + checkVecValues(restPositionCoefficient); - setVecValues(5); - checkVecValues(5); + setVecValues(freePositionCoefficient); + checkVecValues(freePositionCoefficient); - setVecValues(1); - checkVecValues(1); + setVecValues(velocityCoefficient); + checkVecValues(velocityCoefficient); - setVecValues(3); - checkVecValues(3); + setVecValues(forceCoefficient); + checkVecValues(forceCoefficient); - setVecValues(8); - checkVecValues(8); + setVecValues(freeVelocityCoefficient); + checkVecValues(freeVelocityCoefficient); } template @@ -116,8 +123,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest m_mechanicalObject->vOp(nullptr, core::VecId::null()); } - checkVecValues(1); - checkVecValues(1); + checkVecValues(positionCoefficient); + checkVecValues(velocityCoefficient); return true; } @@ -140,7 +147,7 @@ struct MechanicalObjectVOpTest : public testing::BaseTest } } - checkVecValues(1); + checkVecValues(velocityCoefficient); } void resetVelocity() const @@ -161,7 +168,7 @@ struct MechanicalObjectVOpTest : public testing::BaseTest } } - checkVecValues(1); + checkVecValues(positionCoefficient); } void multiplyByScalarPosition() const @@ -171,8 +178,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v *= f m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::ConstVecId::null(), core::vec_id::read_access::position, 2._sreal); } - checkVecSpatialValues(2); - checkVecValues(1); + checkVecSpatialValues(positionCoefficient * 2_sreal); + checkVecValues(velocityCoefficient); } void multiplyByScalarVelocity() const @@ -182,8 +189,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v *= f m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::ConstVecId::null(), core::vec_id::read_access::velocity, 2._sreal); } - checkVecValues(1); - checkVecValues(2); + checkVecValues(positionCoefficient); + checkVecValues(velocityCoefficient * 2_sreal); } void equalOtherMultiplyByScalarPosition() const @@ -193,8 +200,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v = b*f m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::ConstVecId::null(), core::vec_id::read_access::restPosition, 2._sreal); } - checkVecSpatialValues(4); - checkVecValues(1); + checkVecSpatialValues(restPositionCoefficient * 2); + checkVecValues(velocityCoefficient); } void equalOtherMultiplyByScalarVelocity() const @@ -204,8 +211,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v = b*f m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::ConstVecId::null(), core::vec_id::read_access::force, 2._sreal); } - checkVecValues(1); - checkVecValues(6); + checkVecValues(positionCoefficient); + checkVecValues(forceCoefficient * 2); } void equalOtherMultiplyByScalarPositionMix() const @@ -215,8 +222,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v = b*f m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::ConstVecId::null(), core::vec_id::read_access::velocity, 2._sreal); } - checkVecSpatialValues(1); - checkVecValues(1); + checkVecSpatialValues(positionCoefficient); + checkVecValues(velocityCoefficient); } void equalOtherMultiplyByScalarVelocityMix() const @@ -226,8 +233,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v = b*f m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::ConstVecId::null(), core::vec_id::read_access::position, 2._sreal); } - checkVecSpatialValues(1); - checkVecValues(1); + checkVecSpatialValues(positionCoefficient); + checkVecValues(velocityCoefficient); } void equalOtherPosition() const @@ -237,8 +244,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v = a m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::vec_id::read_access::restPosition, core::ConstVecId::null(), 1._sreal); } - checkVecValues(2); - checkVecValues(1); + checkVecValues(restPositionCoefficient); + checkVecValues(velocityCoefficient); } void equalOtherPositionMix() const @@ -248,8 +255,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v = a m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::vec_id::read_access::velocity, core::ConstVecId::null(), 1._sreal); } - checkVecValues(1); - checkVecValues(1); + checkVecValues(positionCoefficient); + checkVecValues(velocityCoefficient); } void equalOtherVelocity() const @@ -259,8 +266,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v = a m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::vec_id::read_access::force, core::ConstVecId::null(), 1._sreal); } - checkVecValues(1); - checkVecValues(3); + checkVecValues(positionCoefficient); + checkVecValues(forceCoefficient); } void equalOtherVelocityMix() const @@ -270,8 +277,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v = a m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::vec_id::read_access::restPosition, core::ConstVecId::null(), 1._sreal); } - checkVecValues(1); - checkVecValues(1); + checkVecValues(positionCoefficient); + checkVecValues(velocityCoefficient); } void plusEqualOtherPosition() const @@ -281,8 +288,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v += b m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::vec_id::read_access::position, core::vec_id::read_access::restPosition, 1._sreal); } - checkVecSpatialValues(3); - checkVecValues(1); + checkVecSpatialValues(positionCoefficient + restPositionCoefficient); + checkVecValues(velocityCoefficient); } void plusEqualOtherPositionMix() const @@ -292,8 +299,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v += b m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::vec_id::read_access::position, core::vec_id::read_access::freeVelocity, 1._sreal); } - checkVecSpatialValues(8+1); - checkVecValues(1); + checkVecSpatialValues(positionCoefficient + freeVelocityCoefficient); + checkVecValues(velocityCoefficient); } void plusEqualOtherVelocity() const @@ -303,8 +310,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v += b m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::vec_id::read_access::velocity, core::vec_id::read_access::force, 1._sreal); } - checkVecValues(1); - checkVecValues(4); + checkVecValues(positionCoefficient); + checkVecValues(velocityCoefficient + forceCoefficient); } void plusEqualOtherVelocityMix() const @@ -314,8 +321,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v += b m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::vec_id::read_access::velocity, core::vec_id::read_access::position, 1._sreal); } - checkVecValues(1); - checkVecValues(1); + checkVecValues(positionCoefficient); + checkVecValues(velocityCoefficient); } void plusEqualOtherMultipliedByScalarPosition() const @@ -325,8 +332,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v += b*f m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::vec_id::read_access::position, core::vec_id::read_access::restPosition, 2._sreal); } - checkVecSpatialValues(5); - checkVecValues(1); + checkVecSpatialValues(positionCoefficient + restPositionCoefficient * 2); + checkVecValues(velocityCoefficient); } void plusEqualOtherMultipliedByScalarPositionMix() const @@ -336,8 +343,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v += b*f m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::vec_id::read_access::position, core::vec_id::read_access::freeVelocity, 2._sreal); } - checkVecSpatialValues(8*2+1); - checkVecValues(1); + checkVecSpatialValues(positionCoefficient + freeVelocityCoefficient * 2); + checkVecValues(velocityCoefficient); } void plusEqualOtherMultipliedByScalarVelocity() const @@ -347,8 +354,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v += b*f m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::vec_id::read_access::velocity, core::vec_id::read_access::force, 2._sreal); } - checkVecValues(1); - checkVecValues(7); + checkVecValues(positionCoefficient); + checkVecValues(velocityCoefficient + forceCoefficient * 2); } void plusEqualOtherMultipliedByScalarVelocityMix() const @@ -358,8 +365,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v += b*f m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::vec_id::read_access::velocity, core::vec_id::read_access::freePosition, 2._sreal); } - checkVecValues(1); - checkVecValues(1); + checkVecValues(positionCoefficient); + checkVecValues(velocityCoefficient); } void plusEqualOtherPosition_2() const @@ -369,8 +376,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v += a m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::vec_id::read_access::restPosition, core::vec_id::read_access::position, 1._sreal); } - checkVecSpatialValues(3); - checkVecValues(1); + checkVecSpatialValues(positionCoefficient + restPositionCoefficient); + checkVecValues(velocityCoefficient); } void plusEqualOtherPositionMix_2() const @@ -380,8 +387,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v += a m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::vec_id::read_access::freeVelocity, core::vec_id::read_access::position, 1._sreal); } - checkVecSpatialValues(1); - checkVecValues(1); + checkVecSpatialValues(positionCoefficient); + checkVecValues(velocityCoefficient); } void plusEqualOtherVelocity_2() const @@ -391,8 +398,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v += a m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::vec_id::read_access::force, core::vec_id::read_access::velocity, 1._sreal); } - checkVecValues(1); - checkVecValues(4); + checkVecValues(positionCoefficient); + checkVecValues(velocityCoefficient + forceCoefficient); } void plusEqualOtherVelocityMix_2() const @@ -402,8 +409,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v += a m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::vec_id::read_access::freePosition, core::vec_id::read_access::velocity, 1._sreal); } - checkVecValues(1); - checkVecValues(1); + checkVecValues(positionCoefficient); + checkVecValues(velocityCoefficient); } void multipliedByScalarThenAddOtherPosition() const @@ -413,8 +420,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v = a+v*f m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::vec_id::read_access::restPosition, core::vec_id::read_access::position, 3_sreal); } - checkVecSpatialValues(5); - checkVecValues(1); + checkVecSpatialValues(restPositionCoefficient + positionCoefficient * 3); + checkVecValues(velocityCoefficient); } void multipliedByScalarThenAddOtherPositionMix() const @@ -424,8 +431,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v = a+v*f m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::vec_id::read_access::freeVelocity, core::vec_id::read_access::position, 3_sreal); } - checkVecSpatialValues(1); - checkVecValues(1); + checkVecSpatialValues(positionCoefficient); + checkVecValues(velocityCoefficient); } void multipliedByScalarThenAddOtherVelocity() const @@ -435,8 +442,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v = a+v*f m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::vec_id::read_access::force, core::vec_id::read_access::velocity, 7._sreal); } - checkVecValues(1); - checkVecValues(10); + checkVecValues(positionCoefficient); + checkVecValues(velocityCoefficient * 7 + forceCoefficient); } void multipliedByScalarThenAddOtherVelocityMix() const @@ -446,8 +453,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v = a+v*f m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::vec_id::read_access::freePosition, core::vec_id::read_access::velocity, 7._sreal); } - checkVecValues(1); - checkVecValues(1); + checkVecValues(positionCoefficient); + checkVecValues(velocityCoefficient); } void equalSumPosition() const @@ -457,8 +464,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v = a+b m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::vec_id::read_access::restPosition, core::vec_id::read_access::freePosition, 1_sreal); } - checkVecSpatialValues(7); - checkVecValues(1); + checkVecSpatialValues(restPositionCoefficient + freePositionCoefficient); + checkVecValues(velocityCoefficient); } void equalSumPositionMix1() const @@ -468,8 +475,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v = a+b m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::vec_id::read_access::restPosition, core::vec_id::read_access::freeVelocity, 1_sreal); } - checkVecSpatialValues(2+8); - checkVecValues(1); + checkVecSpatialValues(restPositionCoefficient+freeVelocityCoefficient); + checkVecValues(velocityCoefficient); } void equalSumPositionMix2() const @@ -479,8 +486,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v = a+b m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::vec_id::read_access::freeVelocity, core::vec_id::read_access::freePosition, 1_sreal); } - checkVecSpatialValues(1); - checkVecValues(1); + checkVecSpatialValues(positionCoefficient); + checkVecValues(velocityCoefficient); } void equalSumVelocity() const @@ -490,8 +497,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v = a+b m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::vec_id::read_access::force, core::vec_id::read_access::freeVelocity, 1._sreal); } - checkVecValues(1); - checkVecValues(11); + checkVecValues(positionCoefficient); + checkVecValues(forceCoefficient + freeVelocityCoefficient); } void equalSumVelocityMix1() const @@ -501,8 +508,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v = a+b m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::vec_id::read_access::position, core::vec_id::read_access::freeVelocity, 1._sreal); } - checkVecValues(1); - checkVecValues(1); + checkVecValues(positionCoefficient); + checkVecValues(velocityCoefficient); } void equalSumVelocityMix2() const @@ -512,8 +519,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v = a+b m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::vec_id::read_access::force, core::vec_id::read_access::position, 1._sreal); } - checkVecValues(1); - checkVecValues(1); + checkVecValues(positionCoefficient); + checkVecValues(velocityCoefficient); } void equalSumWithScalarPosition() const @@ -523,8 +530,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v = a+b*f m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::vec_id::read_access::restPosition, core::vec_id::read_access::freePosition, 12_sreal); } - checkVecSpatialValues(5*12 + 2); - checkVecValues(1); + checkVecSpatialValues(restPositionCoefficient + freePositionCoefficient * 12); + checkVecValues(velocityCoefficient); } void equalSumWithScalarPositionMix1() const @@ -534,8 +541,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v = a+b*f m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::vec_id::read_access::velocity, core::vec_id::read_access::freePosition, 12_sreal); } - checkVecSpatialValues(1); - checkVecValues(1); + checkVecSpatialValues(positionCoefficient); + checkVecValues(velocityCoefficient); } void equalSumWithScalarPositionMix2() const @@ -545,8 +552,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v = a+b*f m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::position, core::vec_id::read_access::restPosition, core::vec_id::read_access::freeVelocity, 12_sreal); } - checkVecSpatialValues(8*12+2); - checkVecValues(1); + checkVecSpatialValues(restPositionCoefficient + freeVelocityCoefficient * 12); + checkVecValues(velocityCoefficient); } void equalSumWithScalarVelocity() const @@ -556,8 +563,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v = a+b*f m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::vec_id::read_access::force, core::vec_id::read_access::freeVelocity, 12_sreal); } - checkVecSpatialValues(1); - checkVecValues(8*12 + 3); + checkVecSpatialValues(positionCoefficient); + checkVecValues(forceCoefficient + freeVelocityCoefficient * 12); } void equalSumWithScalarVelocityMix1() const @@ -567,8 +574,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v = a+b*f m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::vec_id::read_access::position, core::vec_id::read_access::freeVelocity, 12_sreal); } - checkVecSpatialValues(1); - checkVecValues(1); + checkVecSpatialValues(positionCoefficient); + checkVecValues(velocityCoefficient); } void equalSumWithScalarVelocityMix2() const @@ -578,8 +585,8 @@ struct MechanicalObjectVOpTest : public testing::BaseTest //v = a+b*f m_mechanicalObject->vOp(nullptr, core::vec_id::write_access::velocity, core::vec_id::read_access::force, core::vec_id::read_access::position, 12_sreal); } - checkVecSpatialValues(1); - checkVecValues(1); + checkVecSpatialValues(positionCoefficient); + checkVecValues(velocityCoefficient); } typename MO::SPtr m_mechanicalObject; @@ -605,6 +612,11 @@ TYPED_TEST(MechanicalObjectVOpTest, resetPosition) this->resetPosition(); } +TYPED_TEST(MechanicalObjectVOpTest, resetVelocity) +{ + this->resetVelocity(); +} + TYPED_TEST(MechanicalObjectVOpTest, multiplyByScalarPosition) { this->multiplyByScalarPosition(); From 0dc8ae9d5b5fd152c4f4f6c34b467f20950d2f8e Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Wed, 22 Jan 2025 14:10:39 +0100 Subject: [PATCH 5/6] missing test --- .../StateContainer/tests/MechanicalObjectVOp_test.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sofa/Component/StateContainer/tests/MechanicalObjectVOp_test.cpp b/Sofa/Component/StateContainer/tests/MechanicalObjectVOp_test.cpp index b1ca88edc2a..30c5c98724b 100644 --- a/Sofa/Component/StateContainer/tests/MechanicalObjectVOp_test.cpp +++ b/Sofa/Component/StateContainer/tests/MechanicalObjectVOp_test.cpp @@ -617,6 +617,11 @@ TYPED_TEST(MechanicalObjectVOpTest, resetVelocity) this->resetVelocity(); } +TYPED_TEST(MechanicalObjectVOpTest, resetVelocity) +{ + this->resetVelocity(); +} + TYPED_TEST(MechanicalObjectVOpTest, multiplyByScalarPosition) { this->multiplyByScalarPosition(); From 5f8e6379d8f32b7012e6e516b9ddcb297678f6fe Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Thu, 23 Jan 2025 11:41:34 +0100 Subject: [PATCH 6/6] remove duplicated test --- .../StateContainer/tests/MechanicalObjectVOp_test.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Sofa/Component/StateContainer/tests/MechanicalObjectVOp_test.cpp b/Sofa/Component/StateContainer/tests/MechanicalObjectVOp_test.cpp index 30c5c98724b..b1ca88edc2a 100644 --- a/Sofa/Component/StateContainer/tests/MechanicalObjectVOp_test.cpp +++ b/Sofa/Component/StateContainer/tests/MechanicalObjectVOp_test.cpp @@ -617,11 +617,6 @@ TYPED_TEST(MechanicalObjectVOpTest, resetVelocity) this->resetVelocity(); } -TYPED_TEST(MechanicalObjectVOpTest, resetVelocity) -{ - this->resetVelocity(); -} - TYPED_TEST(MechanicalObjectVOpTest, multiplyByScalarPosition) { this->multiplyByScalarPosition();