Get rid of EIGEN_TEST_FUNC, unit tests must now be declared with EIGEN_DECLARE_TEST(mytest) { /* code */ }.

This provide several advantages:
- more flexibility in designing unit tests
- unit tests can be glued to speed up compilation
- unit tests are compiled with same predefined macros, which is a requirement for zapcc
This commit is contained in:
Gael Guennebaud 2018-07-17 14:46:15 +02:00
parent 37f4bdd97d
commit 82f0ce2726
255 changed files with 325 additions and 303 deletions

View File

@ -68,8 +68,6 @@ macro(ei_add_test_internal testname testname_with_suffix)
ei_add_target_property(${targetname} COMPILE_FLAGS "-DEIGEN_TEST_MAX_SIZE=${EIGEN_TEST_MAX_SIZE}")
ei_add_target_property(${targetname} COMPILE_FLAGS "-DEIGEN_TEST_FUNC=${testname}")
if(MSVC)
ei_add_target_property(${targetname} COMPILE_FLAGS "/bigobj")
endif()
@ -170,8 +168,6 @@ macro(ei_add_test_internal_sycl testname testname_with_suffix)
ei_add_target_property(${targetname} COMPILE_FLAGS "-DEIGEN_TEST_MAX_SIZE=${EIGEN_TEST_MAX_SIZE}")
ei_add_target_property(${targetname} COMPILE_FLAGS "-DEIGEN_TEST_FUNC=${testname}")
if(MSVC AND NOT EIGEN_SPLIT_LARGE_TESTS)
ei_add_target_property(${targetname} COMPILE_FLAGS "/bigobj")
endif()

View File

@ -145,7 +145,7 @@ template<typename MatrixType> void adjoint(const MatrixType& m)
VERIFY_IS_APPROX(rv1.template cast<Scalar>().dot(v1), rv1.dot(v1));
}
void test_adjoint()
EIGEN_DECLARE_TEST(adjoint)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( adjoint(Matrix<float, 1, 1>()) );

View File

@ -449,7 +449,7 @@ template<typename ArrayType> void min_max(const ArrayType& m)
}
void test_array()
EIGEN_DECLARE_TEST(array)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( array(Array<float, 1, 1>()) );

View File

@ -256,7 +256,7 @@ void regrrssion_bug_1410()
VERIFY((internal::traits<MatrixWrapper<Array4i> >::Flags&LvalueBit)==LvalueBit);
}
void test_array_for_matrix()
EIGEN_DECLARE_TEST(array_for_matrix)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( array_for_matrix(Matrix<float, 1, 1>()) );

View File

@ -9,7 +9,7 @@
#include "main.h"
void test_array_of_string()
EIGEN_DECLARE_TEST(array_of_string)
{
typedef Array<std::string,1,Dynamic> ArrayXs;
ArrayXs a1(3), a2(3), a3(3), a3ref(3);

View File

@ -68,7 +68,7 @@ template<typename MatrixType> void replicate(const MatrixType& m)
VERIFY_IS_APPROX(vx1, v1.colwise().replicate(f2));
}
void test_array_replicate()
EIGEN_DECLARE_TEST(array_replicate)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( replicate(Matrix<float, 1, 1>()) );

View File

@ -123,7 +123,7 @@ template<typename MatrixType> void reverse(const MatrixType& m)
VERIFY_IS_APPROX(x, m1(r, cols - 1 - c));
}
void test_array_reverse()
EIGEN_DECLARE_TEST(array_reverse)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( reverse(Matrix<float, 1, 1>()) );

View File

@ -59,7 +59,7 @@ template<typename MatrixType> void bandmatrix(const MatrixType& _m)
using Eigen::internal::BandMatrix;
void test_bandmatrix()
EIGEN_DECLARE_TEST(bandmatrix)
{
for(int i = 0; i < 10*g_repeat ; i++) {
Index rows = internal::random<Index>(1,10);

View File

@ -268,7 +268,7 @@ void fixedSizeMatrixConstruction()
}
}
void test_basicstuff()
EIGEN_DECLARE_TEST(basicstuff)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( basicStuff(Matrix<float, 1, 1>()) );

View File

@ -62,7 +62,7 @@ void compare_bdc_jacobi(const MatrixType& a = MatrixType(), unsigned int computa
if(computationOptions & ComputeThinV) VERIFY_IS_APPROX(bdc_svd.matrixV(), jacobi_svd.matrixV());
}
void test_bdcsvd()
EIGEN_DECLARE_TEST(bdcsvd)
{
CALL_SUBTEST_3(( svd_verify_assert<BDCSVD<Matrix3f> >(Matrix3f()) ));
CALL_SUBTEST_4(( svd_verify_assert<BDCSVD<Matrix4d> >(Matrix4d()) ));

View File

@ -26,7 +26,7 @@ template<typename T, typename I> void test_bicgstab_T()
//CALL_SUBTEST( check_sparse_square_solving(bicgstab_colmajor_ssor) );
}
void test_bicgstab()
EIGEN_DECLARE_TEST(bicgstab)
{
CALL_SUBTEST_1((test_bicgstab_T<double,int>()) );
CALL_SUBTEST_2((test_bicgstab_T<std::complex<double>, int>()));

View File

@ -276,7 +276,7 @@ void data_and_stride(const MatrixType& m)
compare_using_data_and_stride(m1.col(c1).transpose());
}
void test_block()
EIGEN_DECLARE_TEST(block)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( block(Matrix<float, 1, 1>()) );

View File

@ -145,7 +145,7 @@ namespace Eigen {
}
void test_boostmultiprec()
EIGEN_DECLARE_TEST(boostmultiprec)
{
typedef Matrix<Real,Dynamic,Dynamic> Mat;
typedef Matrix<std::complex<Real>,Dynamic,Dynamic> MatC;

View File

@ -488,7 +488,7 @@ template<typename MatrixType> void cholesky_verify_assert()
VERIFY_RAISES_ASSERT(ldlt.solveInPlace(&tmp))
}
void test_cholesky()
EIGEN_DECLARE_TEST(cholesky)
{
int s = 0;
for(int i = 0; i < g_repeat; i++) {

View File

@ -55,7 +55,7 @@ template<typename T, int flags, typename IdxType> void test_cholmod_T()
test_cholmod_ST<SparseMatrix<T, flags, IdxType> >();
}
void test_cholmod_support()
EIGEN_DECLARE_TEST(cholmod_support)
{
CALL_SUBTEST_11( (test_cholmod_T<double , ColMajor, int >()) );
CALL_SUBTEST_12( (test_cholmod_T<double , ColMajor, long>()) );

View File

@ -65,7 +65,7 @@ struct test_block_recursion<-1>
static void run() { }
};
void test_commainitializer()
EIGEN_DECLARE_TEST(commainitializer)
{
Matrix3d m3;
Matrix4d m4;

View File

@ -26,7 +26,7 @@ template<typename T, typename I> void test_conjugate_gradient_T()
CALL_SUBTEST( check_sparse_spd_solving(cg_colmajor_upper_I) );
}
void test_conjugate_gradient()
EIGEN_DECLARE_TEST(conjugate_gradient)
{
CALL_SUBTEST_1(( test_conjugate_gradient_T<double,int>() ));
CALL_SUBTEST_2(( test_conjugate_gradient_T<std::complex<double>, int>() ));

View File

@ -109,7 +109,7 @@ void run_vector_tests()
}
}
void test_conservative_resize()
EIGEN_DECLARE_TEST(conservative_resize)
{
for(int i=0; i<g_repeat; ++i)
{

View File

@ -37,7 +37,7 @@ template<typename MatrixType> void ctor_init1(const MatrixType& m)
}
void test_constructor()
EIGEN_DECLARE_TEST(constructor)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( ctor_init1(Matrix<float, 1, 1>()) );

View File

@ -101,7 +101,7 @@ template<typename MatrixType, int CRows, int CCols, int SRows, int SCols> void c
VERIFY_IS_EQUAL((const_matrix.template rightCols<c>()), (const_matrix.template block<rows,c>(0,cols-c)));
}
void test_corners()
EIGEN_DECLARE_TEST(corners)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( corners(Matrix<float, 1, 1>()) );

View File

@ -33,7 +33,7 @@ Index Foo::object_limit = 0;
#undef EIGEN_TEST_MAX_SIZE
#define EIGEN_TEST_MAX_SIZE 3
void test_ctorleak()
EIGEN_DECLARE_TEST(ctorleak)
{
typedef Matrix<Foo, Dynamic, Dynamic> MatrixX;
typedef Matrix<Foo, Dynamic, 1> VectorX;

View File

@ -182,7 +182,7 @@ void test_denseLM_T()
}
void test_denseLM()
EIGEN_DECLARE_TEST(denseLM)
{
CALL_SUBTEST_2(test_denseLM_T<double>());

View File

@ -52,7 +52,7 @@ void dense_storage_assignment()
VERIFY_IS_EQUAL(raw_reference[i], raw_copied_reference[i]);
}
void test_dense_storage()
EIGEN_DECLARE_TEST(dense_storage)
{
dense_storage_copy<int,Dynamic,Dynamic>();
dense_storage_copy<int,Dynamic,3>();

View File

@ -50,7 +50,7 @@ template<typename MatrixType> void determinant(const MatrixType& m)
VERIFY_IS_APPROX(m2.block(0,0,0,0).determinant(), Scalar(1));
}
void test_determinant()
EIGEN_DECLARE_TEST(determinant)
{
for(int i = 0; i < g_repeat; i++) {
int s = 0;

View File

@ -88,7 +88,7 @@ template<typename MatrixType> void diagonal_assert(const MatrixType& m) {
VERIFY_RAISES_ASSERT( m1.diagonal(-(rows+1)) );
}
void test_diagonal()
EIGEN_DECLARE_TEST(diagonal)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( diagonal(Matrix<float, 1, 1>()) );

View File

@ -144,7 +144,7 @@ void bug987()
VERIFY_IS_APPROX(( res1 = points.topLeftCorner<2,2>()*diag.asDiagonal()) , res2 = tmp2*diag.asDiagonal() );
}
void test_diagonalmatrices()
EIGEN_DECLARE_TEST(diagonalmatrices)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( diagonalmatrices(Matrix<float, 1, 1>()) );

View File

@ -44,7 +44,7 @@ void dontalign(const MatrixType& m)
internal::aligned_delete(array, rows);
}
void test_dontalign()
EIGEN_DECLARE_TEST(dontalign)
{
#if defined EIGEN_TEST_PART_1 || defined EIGEN_TEST_PART_5
dontalign(Matrix3d());

View File

@ -119,7 +119,7 @@ template<typename T> void check_custom_new_delete()
#endif
}
void test_dynalloc()
EIGEN_DECLARE_TEST(dynalloc)
{
// low level dynamic memory allocation
CALL_SUBTEST(check_handmade_aligned_malloc());

View File

@ -52,7 +52,7 @@ template<typename MatrixType> void eigen2support(const MatrixType& m)
m1.minor(0,0);
}
void test_eigen2support()
EIGEN_DECLARE_TEST(eigen2support)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( eigen2support(Matrix<double,1,1>()) );

View File

@ -152,7 +152,7 @@ template<typename MatrixType> void eigensolver_verify_assert(const MatrixType& m
VERIFY_RAISES_ASSERT(eig.eigenvectors());
}
void test_eigensolver_complex()
EIGEN_DECLARE_TEST(eigensolver_complex)
{
int s = 0;
for(int i = 0; i < g_repeat; i++) {

View File

@ -85,7 +85,7 @@ template<typename MatrixType> void generalized_eigensolver_real(const MatrixType
}
}
void test_eigensolver_generalized_real()
EIGEN_DECLARE_TEST(eigensolver_generalized_real)
{
for(int i = 0; i < g_repeat; i++) {
int s = 0;

View File

@ -100,7 +100,7 @@ template<typename MatrixType> void eigensolver_verify_assert(const MatrixType& m
VERIFY_RAISES_ASSERT(eig.pseudoEigenvectors());
}
void test_eigensolver_generic()
EIGEN_DECLARE_TEST(eigensolver_generic)
{
int s = 0;
for(int i = 0; i < g_repeat; i++) {

View File

@ -230,7 +230,7 @@ void bug_1204()
SelfAdjointEigenSolver<Eigen::SparseMatrix<double> > eig(A);
}
void test_eigensolver_selfadjoint()
EIGEN_DECLARE_TEST(eigensolver_selfadjoint)
{
int s = 0;
for(int i = 0; i < g_repeat; i++) {

View File

@ -101,7 +101,7 @@ using namespace std;
#define VERIFY_IS_APPROX_EVALUATOR(DEST,EXPR) VERIFY_IS_APPROX(copy_using_evaluator(DEST,(EXPR)), (EXPR).eval());
#define VERIFY_IS_APPROX_EVALUATOR2(DEST,EXPR,REF) VERIFY_IS_APPROX(copy_using_evaluator(DEST,(EXPR)), (REF).eval());
void test_evaluators()
EIGEN_DECLARE_TEST(evaluators)
{
// Testing Matrix evaluator and Transpose
Vector2d v = Vector2d::Random();

View File

@ -107,7 +107,7 @@ void memoryleak()
VERIFY(ScalarWithExceptions::instances==0 && "global memory leak detected in " && EIGEN_MAKESTRING(OP)); \
}
void test_exceptions()
EIGEN_DECLARE_TEST(exceptions)
{
CALL_SUBTEST( memoryleak() );
}

View File

@ -88,7 +88,7 @@ void check_inf_nan(bool dryrun) {
}
}
void test_fastmath() {
EIGEN_DECLARE_TEST(fastmath) {
std::cout << "*** float *** \n\n"; check_inf_nan<float>(true);
std::cout << "*** double ***\n\n"; check_inf_nan<double>(true);
std::cout << "*** long double *** \n\n"; check_inf_nan<long double>(true);

View File

@ -26,7 +26,7 @@ void test_none_aligned_helper(Scalar *array, int size)
struct some_non_vectorizable_type { float x; };
void test_first_aligned()
EIGEN_DECLARE_TEST(first_aligned)
{
EIGEN_ALIGN16 float array_float[100];
test_first_aligned_helper(array_float, 50);

View File

@ -169,7 +169,7 @@ void specificTest2()
}
void test_geo_alignedbox()
EIGEN_DECLARE_TEST(geo_alignedbox)
{
for(int i = 0; i < g_repeat; i++)
{

View File

@ -103,7 +103,7 @@ template<typename Scalar> void eulerangles()
check_all_var(ea);
}
void test_geo_eulerangles()
EIGEN_DECLARE_TEST(geo_eulerangles)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( eulerangles<float>() );

View File

@ -115,7 +115,7 @@ template<typename Scalar,int Size> void homogeneous(void)
VERIFY_IS_APPROX( (t2.template triangularView<Lower>() * v0.homogeneous()).eval(), (t2.template triangularView<Lower>()*hv0) );
}
void test_geo_homogeneous()
EIGEN_DECLARE_TEST(geo_homogeneous)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1(( homogeneous<float,1>() ));

View File

@ -180,7 +180,7 @@ template<typename Scalar> void hyperplane_alignment()
}
void test_geo_hyperplane()
EIGEN_DECLARE_TEST(geo_hyperplane)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( hyperplane(Hyperplane<float,2>()) );

View File

@ -115,7 +115,7 @@ template<typename Scalar, int Size> void orthomethods(int size=Size)
VERIFY_IS_APPROX(mcrossN3.row(i), matN3.row(i).cross(vec3));
}
void test_geo_orthomethods()
EIGEN_DECLARE_TEST(geo_orthomethods)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( orthomethods_3<float>() );

View File

@ -117,7 +117,7 @@ template<typename Scalar> void parametrizedline_alignment()
#endif
}
void test_geo_parametrizedline()
EIGEN_DECLARE_TEST(geo_parametrizedline)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( parametrizedline(ParametrizedLine<float,2>()) );

View File

@ -285,7 +285,7 @@ template<typename PlainObjectType> void check_const_correctness(const PlainObjec
VERIFY( !(Map<ConstPlainObjectType, Aligned>::Flags & LvalueBit) );
}
void test_geo_quaternion()
EIGEN_DECLARE_TEST(geo_quaternion)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1(( quaternion<float,AutoAlign>() ));

View File

@ -612,7 +612,7 @@ template<typename Scalar, int Dim, int Options> void transform_products()
VERIFY_IS_APPROX((ac*p).matrix(), a_m*p_m);
}
void test_geo_transformations()
EIGEN_DECLARE_TEST(geo_transformations)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1(( transformations<double,Affine,AutoAlign>() ));

View File

@ -15,7 +15,6 @@
#define EIGEN_TEST_NO_LONGDOUBLE
#define EIGEN_TEST_NO_COMPLEX
#define EIGEN_TEST_FUNC gpu_basic
#define EIGEN_DEFAULT_DENSE_INDEX_TYPE int
#include "main.h"
@ -162,7 +161,7 @@ struct matrix_inverse {
}
};
void test_gpu_basic()
EIGEN_DECLARE_TEST(gpu_basic)
{
ei_test_init_gpu();

View File

@ -272,7 +272,7 @@ void test_product()
VERIFY_IS_APPROX(Ch.noalias()+=Ah*Bh, (Cf.noalias()+=Af*Bf).cast<half>());
}
void test_half_float()
EIGEN_DECLARE_TEST(half_float)
{
CALL_SUBTEST(test_numtraits());
for(int i = 0; i < g_repeat; i++) {

View File

@ -49,7 +49,7 @@ template<typename Scalar,int Size> void hessenberg(int size = Size)
// TODO: Add tests for packedMatrix() and householderCoefficients()
}
void test_hessenberg()
EIGEN_DECLARE_TEST(hessenberg)
{
CALL_SUBTEST_1(( hessenberg<std::complex<double>,1>() ));
CALL_SUBTEST_2(( hessenberg<std::complex<double>,2>() ));

View File

@ -133,7 +133,7 @@ template<typename MatrixType> void householder(const MatrixType& m)
VERIFY_IS_APPROX(m3 * m5, m1); // test evaluating rhseq to a dense matrix, then applying
}
void test_householder()
EIGEN_DECLARE_TEST(householder)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( householder(Matrix<double,2,2>()) );

View File

@ -29,7 +29,7 @@ template<typename T, typename I> void test_incomplete_cholesky_T()
CALL_SUBTEST( check_sparse_spd_solving(cg_illt_uplo_amd) );
}
void test_incomplete_cholesky()
EIGEN_DECLARE_TEST(incomplete_cholesky)
{
CALL_SUBTEST_1(( test_incomplete_cholesky_T<double,int>() ));
CALL_SUBTEST_2(( test_incomplete_cholesky_T<std::complex<double>, int>() ));

View File

@ -388,7 +388,7 @@ void check_indexed_view()
}
void test_indexed_view()
EIGEN_DECLARE_TEST(indexed_view)
{
// for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( check_indexed_view() );

View File

@ -79,7 +79,7 @@ template<typename DecType,typename MatrixType> void inplace(bool square = false,
}
void test_inplace_decomposition()
EIGEN_DECLARE_TEST(inplace_decomposition)
{
EIGEN_UNUSED typedef Matrix<double,4,3> Matrix43d;
for(int i = 0; i < g_repeat; i++) {

View File

@ -131,7 +131,7 @@ template<typename MatrixType> void integer_type_tests(const MatrixType& m)
VERIFY_IS_APPROX((m1 * m2.transpose()) * m1, m1 * (m2.transpose() * m1));
}
void test_integer_types()
EIGEN_DECLARE_TEST(integer_types)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( integer_type_tests(Matrix<unsigned int, 1, 1>()) );

View File

@ -92,7 +92,7 @@ template<typename MatrixType> void inverse(const MatrixType& m)
}
}
void test_inverse()
EIGEN_DECLARE_TEST(inverse)
{
int s = 0;
for(int i = 0; i < g_repeat; i++) {

View File

@ -11,7 +11,7 @@
using internal::is_same_dense;
void test_is_same_dense()
EIGEN_DECLARE_TEST(is_same_dense)
{
typedef Matrix<double,Dynamic,Dynamic,ColMajor> ColMatrixXd;
typedef Matrix<std::complex<double>,Dynamic,Dynamic,ColMajor> ColMatrixXcd;

View File

@ -57,7 +57,7 @@ void jacobi(const MatrixType& m = MatrixType())
}
}
void test_jacobi()
EIGEN_DECLARE_TEST(jacobi)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1(( jacobi<Matrix3f, float>() ));

View File

@ -69,7 +69,7 @@ void jacobisvd_method()
VERIFY_IS_APPROX(m.jacobiSvd(ComputeFullU|ComputeFullV).solve(m), m);
}
void test_jacobisvd()
EIGEN_DECLARE_TEST(jacobisvd)
{
CALL_SUBTEST_3(( jacobisvd_verify_assert(Matrix3f()) ));
CALL_SUBTEST_4(( jacobisvd_verify_assert(Matrix4d()) ));

View File

@ -24,7 +24,7 @@ template<typename T> void test_klu_support_T()
//check_sparse_square_determinant(umfpack_rowmajor);
}
void test_klu_support()
EIGEN_DECLARE_TEST(klu_support)
{
CALL_SUBTEST_1(test_klu_support_T<double>());
CALL_SUBTEST_2(test_klu_support_T<std::complex<double> >());

View File

@ -110,7 +110,7 @@ template<typename MatrixType> void real_complex(DenseIndex rows = MatrixType::Ro
VERIFY(g_called && "matrix<complex> - real not properly optimized");
}
void test_linearstructure()
EIGEN_DECLARE_TEST(linearstructure)
{
g_called = true;
VERIFY(g_called); // avoid `unneeded-internal-declaration` warning.

View File

@ -30,7 +30,7 @@ template<typename T> void test_lscg_T()
CALL_SUBTEST( check_sparse_leastsquare_solving(lscg_rowmajor_I) );
}
void test_lscg()
EIGEN_DECLARE_TEST(lscg)
{
CALL_SUBTEST_1(test_lscg_T<double>());
CALL_SUBTEST_2(test_lscg_T<std::complex<double> >());

View File

@ -242,7 +242,7 @@ template<typename MatrixType> void lu_verify_assert()
VERIFY_RAISES_ASSERT(plu.inverse())
}
void test_lu()
EIGEN_DECLARE_TEST(lu)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( lu_non_invertible<Matrix3f>() );

View File

@ -128,7 +128,6 @@ inline void on_temporary_creation(long int size) {
#endif
// the following file is automatically generated by cmake
#include "split_test_helper.h"
#ifdef NDEBUG
@ -145,10 +144,6 @@ inline void on_temporary_creation(long int size) {
#define EIGEN_MAKING_DOCS
#endif
#ifndef EIGEN_TEST_FUNC
#error EIGEN_TEST_FUNC must be defined
#endif
#define DEFAULT_REPEAT 10
namespace Eigen
@ -157,17 +152,45 @@ namespace Eigen
// level == 0 <=> abort if test fail
// level >= 1 <=> warning message to std::cerr if test fail
static int g_test_level = 0;
static int g_repeat;
static unsigned int g_seed;
static bool g_has_set_repeat, g_has_set_seed;
static int g_repeat = 1;
static unsigned int g_seed = 0;
static bool g_has_set_repeat = false, g_has_set_seed = false;
class EigenTest
{
public:
EigenTest() : m_func(0) {}
EigenTest(const char* a_name, void (*func)(void))
: m_name(a_name), m_func(func)
{
ms_registered_tests.push_back(this);
}
const std::string& name() const { return m_name; }
void operator()() const { m_func(); }
static const std::vector<EigenTest*>& all() { return ms_registered_tests; }
protected:
std::string m_name;
void (*m_func)(void);
static std::vector<EigenTest*> ms_registered_tests;
};
std::vector<EigenTest*> EigenTest::ms_registered_tests;
// Declare and register a test, e.g.:
// EIGEN_DECLARE_TEST(mytest) { ... }
// will create a function:
// void test_mytest() { ... }
// that will be automatically called.
#define EIGEN_DECLARE_TEST(X) \
void EIGEN_CAT(test_,X) (); \
static EigenTest EIGEN_CAT(test_handler_,X) (EIGEN_MAKESTRING(X), & EIGEN_CAT(test_,X)); \
void EIGEN_CAT(test_,X) ()
}
#define TRACK std::cerr << __FILE__ << " " << __LINE__ << std::endl
// #define TRACK while()
#define EI_PP_MAKE_STRING2(S) #S
#define EI_PP_MAKE_STRING(S) EI_PP_MAKE_STRING2(S)
#define EIGEN_DEFAULT_IO_FORMAT IOFormat(4, 0, " ", "\n", "", "", "", "")
#if (defined(_CPPUNWIND) || defined(__EXCEPTIONS)) && !defined(__CUDA_ARCH__) && !defined(__HIP_DEVICE_COMPILE__)
@ -225,7 +248,7 @@ namespace Eigen
} \
else if (Eigen::internal::push_assert) \
{ \
eigen_assert_list.push_back(std::string(EI_PP_MAKE_STRING(__FILE__) " (" EI_PP_MAKE_STRING(__LINE__) ") : " #a) ); \
eigen_assert_list.push_back(std::string(EIGEN_MAKESTRING(__FILE__) " (" EIGEN_MAKESTRING(__LINE__) ") : " #a) ); \
}
#ifdef EIGEN_EXCEPTIONS
@ -338,10 +361,10 @@ inline void verify_impl(bool condition, const char *testname, const char *file,
}
}
#define VERIFY(a) ::verify_impl(a, g_test_stack.back().c_str(), __FILE__, __LINE__, EI_PP_MAKE_STRING(a))
#define VERIFY(a) ::verify_impl(a, g_test_stack.back().c_str(), __FILE__, __LINE__, EIGEN_MAKESTRING(a))
#define VERIFY_GE(a, b) ::verify_impl(a >= b, g_test_stack.back().c_str(), __FILE__, __LINE__, EI_PP_MAKE_STRING(a >= b))
#define VERIFY_LE(a, b) ::verify_impl(a <= b, g_test_stack.back().c_str(), __FILE__, __LINE__, EI_PP_MAKE_STRING(a <= b))
#define VERIFY_GE(a, b) ::verify_impl(a >= b, g_test_stack.back().c_str(), __FILE__, __LINE__, EIGEN_MAKESTRING(a >= b))
#define VERIFY_LE(a, b) ::verify_impl(a <= b, g_test_stack.back().c_str(), __FILE__, __LINE__, EIGEN_MAKESTRING(a <= b))
#define VERIFY_IS_EQUAL(a, b) VERIFY(test_is_equal(a, b, true))
@ -358,7 +381,7 @@ inline void verify_impl(bool condition, const char *testname, const char *file,
#define STATIC_CHECK(COND) EIGEN_STATIC_ASSERT( (COND) , EIGEN_INTERNAL_ERROR_PLEASE_FILE_A_BUG_REPORT )
#define CALL_SUBTEST(FUNC) do { \
g_test_stack.push_back(EI_PP_MAKE_STRING(FUNC)); \
g_test_stack.push_back(EIGEN_MAKESTRING(FUNC)); \
FUNC; \
g_test_stack.pop_back(); \
} while (0)
@ -709,9 +732,6 @@ template<> std::string type_name<std::complex<double> >() { return "comple
template<> std::string type_name<std::complex<long double> >() { return "complex<long double>"; }
template<> std::string type_name<std::complex<int> >() { return "complex<int>"; }
// forward declaration of the main test function
void EIGEN_CAT(test_,EIGEN_TEST_FUNC)();
using namespace Eigen;
inline void set_repeat_from_string(const char *str)
@ -798,9 +818,16 @@ int main(int argc, char *argv[])
srand(g_seed);
std::cout << "Repeating each test " << g_repeat << " times" << std::endl;
Eigen::g_test_stack.push_back(std::string(EI_PP_MAKE_STRING(EIGEN_TEST_FUNC)));
VERIFY(EigenTest::all().size()>0);
for(std::size_t i=0; i<EigenTest::all().size(); ++i)
{
const EigenTest& current_test = *EigenTest::all()[i];
Eigen::g_test_stack.push_back(current_test.name());
current_test();
Eigen::g_test_stack.pop_back();
}
EIGEN_CAT(test_,EIGEN_TEST_FUNC)();
return 0;
}

View File

@ -177,7 +177,7 @@ void map_not_aligned_on_scalar()
internal::aligned_delete(array1, (size+1)*(size+1)+1);
}
void test_mapped_matrix()
EIGEN_DECLARE_TEST(mapped_matrix)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( map_class_vector(Matrix<float, 1, 1>()) );

View File

@ -143,7 +143,7 @@ void mapstaticmethods(const PlainObjectType& m)
VERIFY(true); // just to avoid 'unused function' warning
}
void test_mapstaticmethods()
EIGEN_DECLARE_TEST(mapstaticmethods)
{
ptr = internal::aligned_new<float>(1000);
for(int i = 0; i < 1000; i++) ptr[i] = float(i);

View File

@ -197,7 +197,7 @@ void bug1453()
VERIFY_IS_APPROX(RowMatrix32i::Map(data, InnerStride<>(2)), RowMatrixXi::Map(data, 3, 2, Stride<4,2>()));
}
void test_mapstride()
EIGEN_DECLARE_TEST(mapstride)
{
for(int i = 0; i < g_repeat; i++) {
int maxn = 30;

View File

@ -27,7 +27,7 @@ struct MyImpl : public MyInterface {
void func() {}
};
void test_meta()
EIGEN_DECLARE_TEST(meta)
{
VERIFY((internal::conditional<(3<4),internal::true_type, internal::false_type>::type::value));
VERIFY(( internal::is_same<float,float>::value));

View File

@ -19,7 +19,7 @@ template<typename T> void test_metis_T()
check_sparse_square_solving(sparselu_metis);
}
void test_metis_support()
EIGEN_DECLARE_TEST(metis_support)
{
CALL_SUBTEST_1(test_metis_T<double>());
}

View File

@ -34,7 +34,7 @@ template<typename MatrixType> void miscMatrices(const MatrixType& m)
VERIFY_IS_APPROX(square, MatrixType::Identity(rows, rows));
}
void test_miscmatrices()
EIGEN_DECLARE_TEST(miscmatrices)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( miscMatrices(Matrix<float, 1, 1>()) );

View File

@ -286,7 +286,7 @@ template<int SizeAtCompileType> void mixingtypes(int size = SizeAtCompileType)
VERIFY_IS_APPROX( rcd.noalias() -= mcd + md*md, - ((md*md).eval().template cast<CD>()) );
}
void test_mixingtypes()
EIGEN_DECLARE_TEST(mixingtypes)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1(mixingtypes<3>());

View File

@ -91,7 +91,7 @@ template <typename MatrixType> void run_nesting_ops_2(const MatrixType& _m)
}
void test_nesting_ops()
EIGEN_DECLARE_TEST(nesting_ops)
{
CALL_SUBTEST_1(run_nesting_ops_1(MatrixXf::Random(25,25)));
CALL_SUBTEST_2(run_nesting_ops_1(MatrixXcd::Random(25,25)));

View File

@ -202,7 +202,7 @@ template<typename MatrixType> void test_reference(const MatrixType& m) {
}
void test_nomalloc()
EIGEN_DECLARE_TEST(nomalloc)
{
// create some dynamic objects
Eigen::MatrixXd M1 = MatrixXd::Random(3,3);

View File

@ -239,7 +239,7 @@ void testMatrixType(const MatrixType& m)
VERIFY_IS_APPROX( A(i,j), s1 );
}
void test_nullary()
EIGEN_DECLARE_TEST(nullary)
{
CALL_SUBTEST_1( testMatrixType(Matrix2d()) );
CALL_SUBTEST_2( testMatrixType(MatrixXcf(internal::random<int>(1,300),internal::random<int>(1,300))) );

View File

@ -60,7 +60,7 @@ using TMatrix = Matrix<Scalar,Rows,Cols>;
#endif
void test_num_dimensions()
EIGEN_DECLARE_TEST(num_dimensions)
{
int n = 10;
ArrayXXd A(n,n);

View File

@ -33,7 +33,7 @@ void check_abs() {
}
}
void test_numext() {
EIGEN_DECLARE_TEST(numext) {
CALL_SUBTEST( check_abs<bool>() );
CALL_SUBTEST( check_abs<signed char>() );
CALL_SUBTEST( check_abs<unsigned char>() );

View File

@ -627,7 +627,7 @@ template<typename Scalar> void packetmath_scatter_gather()
}
}
void test_packetmath()
EIGEN_DECLARE_TEST(packetmath)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( packetmath<float>() );

View File

@ -20,7 +20,7 @@ template<typename T> void test_pardiso_T()
check_sparse_square_solving(pardiso_lu);
}
void test_pardiso_support()
EIGEN_DECLARE_TEST(pardiso_support)
{
CALL_SUBTEST_1(test_pardiso_T<float>());
CALL_SUBTEST_2(test_pardiso_T<double>());

View File

@ -45,7 +45,7 @@ template<typename T> void test_pastix_T_LU()
check_sparse_square_solving(pastix_lu);
}
void test_pastix_support()
EIGEN_DECLARE_TEST(pastix_support)
{
CALL_SUBTEST_1(test_pastix_T<float>());
CALL_SUBTEST_2(test_pastix_T<double>());

View File

@ -152,7 +152,7 @@ void bug890()
VERIFY_IS_APPROX(v1, (P.inverse() * rhs).eval());
}
void test_permutationmatrices()
EIGEN_DECLARE_TEST(permutationmatrices)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( permutationmatrices(Matrix<float, 1, 1>()) );

View File

@ -68,7 +68,7 @@ template<typename MatrixType> void inverse_general_4x4(int repeat)
}
}
void test_prec_inverse_4x4()
EIGEN_DECLARE_TEST(prec_inverse_4x4)
{
CALL_SUBTEST_1((inverse_permutation_4x4<Matrix4f>()));
CALL_SUBTEST_1(( inverse_general_4x4<Matrix4f>(200000 * g_repeat) ));

View File

@ -352,7 +352,7 @@ void bug_1308()
VERIFY_IS_APPROX(r44.noalias() += Vector4d::Ones() * m44.col(0).transpose(), ones44);
}
void test_product_extra()
EIGEN_DECLARE_TEST(product_extra)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( product_extra(MatrixXf(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );

View File

@ -30,7 +30,7 @@ void test_aliasing()
x = z;
}
void test_product_large()
EIGEN_DECLARE_TEST(product_large)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( product(MatrixXf(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );

View File

@ -84,7 +84,7 @@ template<typename Scalar> void mmtr(int size)
VERIFY_IS_APPROX(matc, ref2);
}
void test_product_mmtr()
EIGEN_DECLARE_TEST(product_mmtr)
{
for(int i = 0; i < g_repeat ; i++)
{

View File

@ -150,7 +150,7 @@ template<typename MatrixType> void product_notemporary(const MatrixType& m)
VERIFY_EVALUATION_COUNT( rvres.noalias() = rv1 * (m1 * m2.adjoint()), 1 );
}
void test_product_notemporary()
EIGEN_DECLARE_TEST(product_notemporary)
{
int s;
for(int i = 0; i < g_repeat; i++) {

View File

@ -59,7 +59,7 @@ template<typename MatrixType> void product_selfadjoint(const MatrixType& m)
}
}
void test_product_selfadjoint()
EIGEN_DECLARE_TEST(product_selfadjoint)
{
int s = 0;
for(int i = 0; i < g_repeat ; i++) {

View File

@ -228,7 +228,7 @@ void bug_1311()
VERIFY_IS_APPROX(res, A*b);
}
void test_product_small()
EIGEN_DECLARE_TEST(product_small)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( product(Matrix<float, 3, 2>()) );

View File

@ -94,7 +94,7 @@ template<typename Scalar, int Size, int OtherSize> void symm(int size = Size, in
}
void test_product_symm()
EIGEN_DECLARE_TEST(product_symm)
{
for(int i = 0; i < g_repeat ; i++)
{

View File

@ -117,7 +117,7 @@ template<typename MatrixType> void syrk(const MatrixType& m)
((s1 * m1.row(c).adjoint() * m1.row(c).adjoint().adjoint()).eval().template triangularView<Upper>().toDenseMatrix()));
}
void test_product_syrk()
EIGEN_DECLARE_TEST(product_syrk)
{
for(int i = 0; i < g_repeat ; i++)
{

View File

@ -115,7 +115,7 @@ void trmm(int rows=get_random_size<Scalar>(), int cols=get_random_size<Scalar>()
CALL_ALL_ORDERS(EIGEN_CAT(3,NB),SCALAR,StrictlyLower)
void test_product_trmm()
EIGEN_DECLARE_TEST(product_trmm)
{
for(int i = 0; i < g_repeat ; i++)
{

View File

@ -70,7 +70,7 @@ template<typename MatrixType> void trmv(const MatrixType& m)
// TODO check with sub-matrices
}
void test_product_trmv()
EIGEN_DECLARE_TEST(product_trmv)
{
int s = 0;
for(int i = 0; i < g_repeat ; i++) {

View File

@ -73,7 +73,7 @@ template<typename Scalar,int Size, int Cols> void trsolve(int size=Size,int cols
VERIFY_TRSM(cmLhs.template triangularView<Lower>(), rmRhs.col(c));
}
void test_product_trsolve()
EIGEN_DECLARE_TEST(product_trsolve)
{
for(int i = 0; i < g_repeat ; i++)
{

View File

@ -100,7 +100,7 @@ template<typename MatrixType> void qr_verify_assert()
VERIFY_RAISES_ASSERT(qr.logAbsDeterminant())
}
void test_qr()
EIGEN_DECLARE_TEST(qr)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( qr(MatrixXf(internal::random<int>(1,EIGEN_TEST_MAX_SIZE),internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );

View File

@ -296,7 +296,7 @@ template<typename MatrixType> void qr_verify_assert()
VERIFY_RAISES_ASSERT(qr.logAbsDeterminant())
}
void test_qr_colpivoting()
EIGEN_DECLARE_TEST(qr_colpivoting)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( qr<MatrixXf>() );

View File

@ -125,7 +125,7 @@ template<typename MatrixType> void qr_verify_assert()
VERIFY_RAISES_ASSERT(qr.logAbsDeterminant())
}
void test_qr_fullpivoting()
EIGEN_DECLARE_TEST(qr_fullpivoting)
{
for(int i = 0; i < 1; i++) {
CALL_SUBTEST_5( qr<Matrix3f>() );

View File

@ -125,7 +125,7 @@ void check_qtvector_quaternion(const QuaternionType&)
}
}
void test_qtvector()
EIGEN_DECLARE_TEST(qtvector)
{
// some non vectorizable fixed sizes
CALL_SUBTEST(check_qtvector_matrix(Vector2f()));

View File

@ -54,7 +54,7 @@ template<typename Scalar> void check_histogram(Scalar x, Scalar y, int bins)
VERIFY( (((hist.cast<double>()/double(f))-1.0).abs()<0.02).all() );
}
void test_rand()
EIGEN_DECLARE_TEST(rand)
{
long long_ref = NumTraits<long>::highest()/10;
signed char char_offset = (std::min)(g_repeat,64);

View File

@ -75,7 +75,7 @@ template<typename MatrixType> void real_qz(const MatrixType& m)
VERIFY_IS_APPROX(qz.matrixZ()*qz.matrixZ().adjoint(), MatrixType::Identity(dim,dim));
}
void test_real_qz()
EIGEN_DECLARE_TEST(real_qz)
{
int s = 0;
for(int i = 0; i < g_repeat; i++) {

View File

@ -146,7 +146,7 @@ template<typename VectorType> void vectorRedux(const VectorType& w)
VERIFY_RAISES_ASSERT(v.head(0).maxCoeff());
}
void test_redux()
EIGEN_DECLARE_TEST(redux)
{
// the max size cannot be too large, otherwise reduxion operations obviously generate large errors.
int maxsize = (std::min)(100,EIGEN_TEST_MAX_SIZE);

View File

@ -264,7 +264,7 @@ void test_ref_fixed_size_assert()
VERIFY_RAISES_STATIC_ASSERT( Ref<const Vector3f> y = 2*v4; (void)y; );
}
void test_ref()
EIGEN_DECLARE_TEST(ref)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( ref_vector(Matrix<float, 1, 1>()) );

View File

@ -33,7 +33,7 @@ void resizeLikeTest12() { resizeLikeTest<1,2>(); }
void resizeLikeTest1020() { resizeLikeTest<10,20>(); }
void resizeLikeTest31() { resizeLikeTest<3,1>(); }
void test_resize()
EIGEN_DECLARE_TEST(resize)
{
CALL_SUBTEST(resizeLikeTest12() );
CALL_SUBTEST(resizeLikeTest1020() );

View File

@ -43,7 +43,7 @@ template <typename MatrixType>
void rvalue_copyassign(const MatrixType&) {}
#endif
void test_rvalue_types()
EIGEN_DECLARE_TEST(rvalue_types)
{
CALL_SUBTEST_1(rvalue_copyassign( MatrixXf::Random(50,50).eval() ));
CALL_SUBTEST_1(rvalue_copyassign( ArrayXXf::Random(50,50).eval() ));

Some files were not shown because too many files have changed in this diff Show More