SOFA API  1c8b807d
Open source framework for multi-physics simuation
sofa::testing Namespace Reference

Classes

struct  SparseMatrixTest
 
class  BaseSimulationTest
 
class  BaseTest
 Base class for Sofa test fixtures. More...
 
struct  CleanupCheck
 
class  LinearCongruentialRandomGenerator
 A simple deterministic and portable random number generator. More...
 
struct  NumericTest
 Helper functions to compare scalars, vectors, matrices, etc. More...
 
struct  data_traits
 
struct  setRotWrapper
 
struct  setRotWrapper< DataTypes, N, true >
 
struct  setRotWrapper< DataTypes, 2, false >
 
struct  setRotWrapper< DataTypes, N, false >
 
class  GtestMessageFrame
 
class  GtestMessageFrameFailure
 
class  GtestMessageFrameFailureWhenMissing
 
class  GtestMessageFrameIgnore
 
class  GtestMessageHandler
 
class  MainGtestMessageHandlerPrivate
 
class  MessageAsTestFailure
 
class  ExpectMessage
 
class  IgnoreMessage
 
class  MainGtestMessageHandler
 

Functions

void initializeOnce ()
 
SOFA_TESTING_API void init ()
 Initialize the Sofa.Testing library, as well as its dependencies. More...
 
SOFA_TESTING_API bool isInitialized ()
 Return true if and only if theSofa.Testing library has been initialized. More...
 
SOFA_TESTING_API void cleanup ()
 Clean up the resources used by the Sofa.Testing library, as well as its dependencies: SofaDefaultType, SofaHelper. More...
 
SOFA_TESTING_API bool isCleanedUp ()
 Return true if and only if the Sofa.Testing library has been cleaned up. More...
 
template<class Vector , class ReadData >
void copyFromData (Vector &v, const ReadData &d)
 Resize the Vector and copy it from the Data. More...
 
template<class WriteData , class Vector >
void copyToData (WriteData &d, const Vector &v)
 Copy the Vector to the Data. They must have the same size. More...
 
template<class DataTypes >
void setRot (typename DataTypes::Coord &coord, const sofa::type::Quat< SReal > &rot)
 
template<class DataTypes >
DataTypes::Coord createCoord (const sofa::type::Vec3 &pos, const sofa::type::Quat< SReal > &rot)
 Create a coord of the specified type from a Vec3 and a Quater. More...
 
template<sofa::Size N, class real >
void EXPECT_VEC_DOUBLE_EQ (sofa::type::Vec< N, real > const &expected, sofa::type::Vec< N, real > const &actual)
 
template<sofa::Size L, sofa::Size C, class real >
void EXPECT_MAT_DOUBLE_EQ (sofa::type::Mat< L, C, real > const &expected, sofa::type::Mat< L, C, real > const &actual)
 
template<sofa::Size L, sofa::Size C, class real >
void EXPECT_MAT_NEAR (sofa::type::Mat< L, C, real > const &expected, sofa::type::Mat< L, C, real > const &actual, real abs_error)
 

Variables

const SReal g_minDeltaErrorRatio = .1
 acceptable ratio between finite difference delta and error threshold More...
 

Detailed Description

This file organization:

  • PRIVATE DECLARATION (the class that are only used internally)
  • PRIVATE DEFINITION (the implementation of the private classes)
  • PUBLIC DEFINITION (the implementation of the public classes)

This file is providing an API to combine gtest and msg_* API. The underlying idea is to be able to test sofa's message.

The API is composed of two macro:

  • EXPECT_MSG_EMIT(...);
  • EXPECT_MSG_NOEMIT(...);

The first one generates a gtest failure when a message of a given type is not emitted. So You need to use it express that the good behavior from the object is to rise a message.

The second one generates a gtest failure when a message of a given type is emitted.

Examples of use: for(BaseLoader* b : objectlist) { EXPECT_MESSAGE_NOEMIT(Warning); EXPECT_MESSAGE_EMIT(Error); b->load("Invalid file"); }

To work the API need to a specific handler to be install in the messaging system. This means that we need to install the message handler using. This is not done automatically To not add something with a linear time complexity in the process.

Example of installation: MessageDispatcher::addHandler( MainGtestMessageHandler::getInstance() ) ;

NB: This is done automatically if you are inhering from Sofa_test.

Function Documentation

◆ cleanup()

SOFA_TESTING_API void sofa::testing::cleanup ( )

Clean up the resources used by the Sofa.Testing library, as well as its dependencies: SofaDefaultType, SofaHelper.

◆ copyFromData()

template<class Vector , class ReadData >
void sofa::testing::copyFromData ( Vector &  v,
const ReadData &  d 
)

Resize the Vector and copy it from the Data.

◆ copyToData()

template<class WriteData , class Vector >
void sofa::testing::copyToData ( WriteData &  d,
const Vector &  v 
)

Copy the Vector to the Data. They must have the same size.

◆ createCoord()

template<class DataTypes >
DataTypes::Coord sofa::testing::createCoord ( const sofa::type::Vec3 pos,
const sofa::type::Quat< SReal > &  rot 
)

Create a coord of the specified type from a Vec3 and a Quater.

◆ EXPECT_MAT_DOUBLE_EQ()

template<sofa::Size L, sofa::Size C, class real >
void sofa::testing::EXPECT_MAT_DOUBLE_EQ ( sofa::type::Mat< L, C, real > const &  expected,
sofa::type::Mat< L, C, real > const &  actual 
)

◆ EXPECT_MAT_NEAR()

template<sofa::Size L, sofa::Size C, class real >
void sofa::testing::EXPECT_MAT_NEAR ( sofa::type::Mat< L, C, real > const &  expected,
sofa::type::Mat< L, C, real > const &  actual,
real  abs_error 
)

◆ EXPECT_VEC_DOUBLE_EQ()

template<sofa::Size N, class real >
void sofa::testing::EXPECT_VEC_DOUBLE_EQ ( sofa::type::Vec< N, real > const &  expected,
sofa::type::Vec< N, real > const &  actual 
)

◆ init()

SOFA_TESTING_API void sofa::testing::init ( )

Initialize the Sofa.Testing library, as well as its dependencies.

◆ initializeOnce()

void sofa::testing::initializeOnce ( )

◆ isCleanedUp()

SOFA_TESTING_API bool sofa::testing::isCleanedUp ( )

Return true if and only if the Sofa.Testing library has been cleaned up.

◆ isInitialized()

SOFA_TESTING_API bool sofa::testing::isInitialized ( )

Return true if and only if theSofa.Testing library has been initialized.

◆ setRot()

template<class DataTypes >
void sofa::testing::setRot ( typename DataTypes::Coord &  coord,
const sofa::type::Quat< SReal > &  rot 
)

Variable Documentation

◆ g_minDeltaErrorRatio

const SReal sofa::testing::g_minDeltaErrorRatio = .1

acceptable ratio between finite difference delta and error threshold