Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert Simulation tests to catch2 #3897

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
545 changes: 233 additions & 312 deletions OpenSim/Simulation/Test/testInverseKinematicsSolver.cpp

Large diffs are not rendered by default.

73 changes: 7 additions & 66 deletions OpenSim/Simulation/Test/testManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,71 +47,12 @@ Manager Tests:
#include <OpenSim/Common/LoadOpenSimLibrary.h>
#include <OpenSim/Simulation/Control/PrescribedController.h>
#include <OpenSim/Common/Constant.h>
#include <catch2/catch_all.hpp>

using namespace OpenSim;
using namespace std;
void testStationCalcWithManager();
void testStateChangesBetweenIntegration();
void testExcitationUpdatesWithManager();
void testConstructors();
void testIntegratorInterface();
void testExceptions();

int main()
{
SimTK::Array_<std::string> failures;

try { testStationCalcWithManager(); }
catch (const std::exception& e) {
cout << e.what() << endl;
failures.push_back("testStationCalcWithManager");
}

try { testStateChangesBetweenIntegration(); }
catch (const std::exception& e) {
cout << e.what() << endl;
failures.push_back("testStateChangesBetweenIntegration");
}

try { testExcitationUpdatesWithManager(); }
catch (const std::exception& e) {
cout << e.what() << endl;
failures.push_back("testExcitationUpdatesWithManager");
}

try { testConstructors(); }
catch (const std::exception& e) {
cout << e.what() << endl;
failures.push_back("testConstructors");
}

try { testIntegratorInterface(); }
catch (const std::exception& e) {
cout << e.what() << endl;
failures.push_back("testIntegratorInterface");
}

try { testExceptions(); }
catch (const std::exception& e) {
cout << e.what() << endl;
failures.push_back("testExceptions");
}

if (!failures.empty()) {
cout << "Done, with failure(s): " << failures << endl;
return 1;
}

cout << "Done. All cases passed." << endl;

return 0;
}

//==============================================================================
// Test Cases
//==============================================================================

void testStationCalcWithManager()
TEST_CASE("testStationCalcWithManager")
{
using SimTK::Vec3;

Expand Down Expand Up @@ -185,7 +126,7 @@ void testStationCalcWithManager()
}
}

void testStateChangesBetweenIntegration()
TEST_CASE("testStateChangesBetweenIntegration")
{
cout << "Running testStateChangesBetweenIntegration" << endl;

Expand Down Expand Up @@ -275,7 +216,7 @@ void testStateChangesBetweenIntegration()

}

void testExcitationUpdatesWithManager()
TEST_CASE("testExcitationUpdatesWithManager")
{
cout << "Running testExcitationUpdatesWithManager" << endl;
LoadOpenSimLibrary("osimActuators");
Expand Down Expand Up @@ -324,7 +265,7 @@ void testExcitationUpdatesWithManager()
}
}

void testConstructors()
TEST_CASE("testConstructors")
{
cout << "Running testConstructors" << endl;

Expand Down Expand Up @@ -382,7 +323,7 @@ void testConstructors()
SimTK_TEST_EQ(sliderCoord.getSpeedValue(outState4), finalSpeed);
}

void testIntegratorInterface()
TEST_CASE("testIntegratorInterface")
{
cout << "Running testIntegratorInterface" << endl;

Expand Down Expand Up @@ -450,7 +391,7 @@ void testIntegratorInterface()
manager.setIntegratorInternalStepLimit(nSteps);
}

void testExceptions()
TEST_CASE("testExceptions")
{
cout << "Running testExceptions" << endl;
LoadOpenSimLibrary("osimActuators");
Expand Down
22 changes: 4 additions & 18 deletions OpenSim/Simulation/Test/testModelInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,12 @@
#include <OpenSim/Common/LoadOpenSimLibrary.h>

#include <memory>
#include <catch2/catch_all.hpp>

using namespace OpenSim;
using namespace std;

void testModelFinalizePropertiesAndConnections();
void testModelTopologyErrors();
void testDoesNotSegfaultWithUnusualConnections();

int main() {
LoadOpenSimLibrary("osimActuators");

SimTK_START_TEST("testModelInterface");
SimTK_SUBTEST(testModelFinalizePropertiesAndConnections);
SimTK_SUBTEST(testModelTopologyErrors);
SimTK_SUBTEST(testDoesNotSegfaultWithUnusualConnections);
SimTK_END_TEST();
}


void testModelFinalizePropertiesAndConnections()
TEST_CASE("testModelFinalizePropertiesAndConnections")
{
Model model("arm26.osim");

Expand Down Expand Up @@ -146,7 +132,7 @@ void testModelFinalizePropertiesAndConnections()
.getParentFrame().getName() == "elbow_in_humerus");
}

void testModelTopologyErrors()
TEST_CASE("testModelTopologyErrors")
{
Model model("arm26.osim");
model.initSystem();
Expand Down Expand Up @@ -232,7 +218,7 @@ void testModelTopologyErrors()
ASSERT_THROW(JointFramesHaveSameBaseFrame, degenerate.initSystem());
}

void testDoesNotSegfaultWithUnusualConnections()
TEST_CASE("testDoesNotSegfaultWithUnusualConnections")
{
// automated reproduction for bug reported in #3299
//
Expand Down
Loading
Loading