Drake
Drake C++ Documentation
drake::test Namespace Reference

Classes

class  DiagnosticPolicyTestBase
 A base class for test fixtures that involve DiagnosticPolicy output. More...
 
class  LimitMalloc
 Instantiate this class in a unit test scope where malloc (and realloc, etc.) should be disallowed or curtailed. More...
 
struct  LimitMallocParams
 Parameters to control malloc limits. More...
 

Functions

template<typename T , typename InvariantPred = std::equal_to<T>>
bool IsMemcpyMovable (const T &value, const InvariantPred &invariant_pred=InvariantPred())
 Checks if value of T type is movable via memcpy. More...
 
template<typename T = double>
static Eigen::Matrix< Polynomial< T >, Eigen::Dynamic, Eigen::Dynamic > RandomPolynomialMatrix (Eigen::Index num_coefficients_per_polynomial, Eigen::Index rows, Eigen::Index cols)
 Obtains a matrix of random unvariate Polynomials of the specified size. More...
 

Function Documentation

◆ IsMemcpyMovable()

bool drake::test::IsMemcpyMovable ( const T &  value,
const InvariantPred &  invariant_pred = InvariantPred() 
)

Checks if value of T type is movable via memcpy.

That is, it tests memcpy on value keeps a given invariant between value and a copy of it. It uses a binary function object invariant_pred to check for invariance.

Note
Eigen's reallocation mechanisms have an issue. It is moving bytes using memcpy without calling a move constructor. As a result, if a Scalar type of Eigen matrix/array is not IsMemcpyMovable, we have undefined behavior when conservativeResize method is called. This should always be used to test a Scalar used within an Eigen::EigenBase<...> object. Please see https://github.com/RobotLocomotion/drake/issues/5974 for more information.

◆ RandomPolynomialMatrix()

static Eigen::Matrix<Polynomial<T>, Eigen::Dynamic, Eigen::Dynamic> drake::test::RandomPolynomialMatrix ( Eigen::Index  num_coefficients_per_polynomial,
Eigen::Index  rows,
Eigen::Index  cols 
)
static

Obtains a matrix of random unvariate Polynomials of the specified size.