diff options
author | Gael Guennebaud <g.gael@free.fr> | 2015-06-19 16:38:26 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2015-06-19 16:38:26 +0200 |
commit | 6318d53b41641a6048a0311c584be7bcb32b3854 (patch) | |
tree | 9fbd6d8243f2530acb566db9d2063227cbac7231 /test | |
parent | 5c84dd56654b0bc3e6bc09773cc86438b27af005 (diff) |
Factorize VERIFY_EVALUATION_COUNT in unit tests
Diffstat (limited to 'test')
-rw-r--r-- | test/cholesky.cpp | 11 | ||||
-rw-r--r-- | test/main.h | 20 | ||||
-rw-r--r-- | test/product_notemporary.cpp | 16 | ||||
-rw-r--r-- | test/ref.cpp | 17 |
4 files changed, 23 insertions, 41 deletions
diff --git a/test/cholesky.cpp b/test/cholesky.cpp index 16db380f6..d652af5bf 100644 --- a/test/cholesky.cpp +++ b/test/cholesky.cpp @@ -11,21 +11,12 @@ #define EIGEN_NO_ASSERTION_CHECKING #endif -static int nb_temporaries; - -#define EIGEN_DENSE_STORAGE_CTOR_PLUGIN { if(size!=0) nb_temporaries++; } +#define TEST_ENABLE_TEMPORARY_TRACKING #include "main.h" #include <Eigen/Cholesky> #include <Eigen/QR> -#define VERIFY_EVALUATION_COUNT(XPR,N) {\ - nb_temporaries = 0; \ - XPR; \ - if(nb_temporaries!=N) std::cerr << "nb_temporaries == " << nb_temporaries << "\n"; \ - VERIFY( (#XPR) && nb_temporaries==N ); \ - } - template<typename MatrixType,template <typename,int> class CholType> void test_chol_update(const MatrixType& symm) { typedef typename MatrixType::Scalar Scalar; diff --git a/test/main.h b/test/main.h index 04c6722a4..ef471acc8 100644 --- a/test/main.h +++ b/test/main.h @@ -69,6 +69,26 @@ // shuts down ICC's remark #593: variable "XXX" was set but never used #define TEST_SET_BUT_UNUSED_VARIABLE(X) EIGEN_UNUSED_VARIABLE(X) +#ifdef TEST_ENABLE_TEMPORARY_TRACKING + +static long int nb_temporaries; + +inline void on_temporary_creation(long int size) { + // here's a great place to set a breakpoint when debugging failures in this test! + if(size!=0) nb_temporaries++; +} + +#define EIGEN_DENSE_STORAGE_CTOR_PLUGIN { on_temporary_creation(size); } + +#define VERIFY_EVALUATION_COUNT(XPR,N) {\ + nb_temporaries = 0; \ + XPR; \ + if(nb_temporaries!=N) std::cerr << "nb_temporaries == " << nb_temporaries << "\n"; \ + VERIFY( (#XPR) && nb_temporaries==N ); \ + } + +#endif + // the following file is automatically generated by cmake #include "split_test_helper.h" diff --git a/test/product_notemporary.cpp b/test/product_notemporary.cpp index 898f1d1cb..9fa69d901 100644 --- a/test/product_notemporary.cpp +++ b/test/product_notemporary.cpp @@ -7,24 +7,10 @@ // Public License v. 2.0. If a copy of the MPL was not distributed // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -static long int nb_temporaries; - -inline void on_temporary_creation(long int size) { - // here's a great place to set a breakpoint when debugging failures in this test! - if(size!=0) nb_temporaries++; -} - -#define EIGEN_DENSE_STORAGE_CTOR_PLUGIN { on_temporary_creation(size); } +#define TEST_ENABLE_TEMPORARY_TRACKING #include "main.h" -#define VERIFY_EVALUATION_COUNT(XPR,N) {\ - nb_temporaries = 0; \ - XPR; \ - if(nb_temporaries!=N) std::cerr << "nb_temporaries == " << nb_temporaries << "\n"; \ - VERIFY( (#XPR) && nb_temporaries==N ); \ - } - template<typename MatrixType> void product_notemporary(const MatrixType& m) { /* This test checks the number of temporaries created diff --git a/test/ref.cpp b/test/ref.cpp index fbe2c450f..18a89f4e9 100644 --- a/test/ref.cpp +++ b/test/ref.cpp @@ -12,25 +12,10 @@ #undef EIGEN_DEFAULT_TO_ROW_MAJOR #endif -static long int nb_temporaries; - -inline void on_temporary_creation(long int) { - // here's a great place to set a breakpoint when debugging failures in this test! - nb_temporaries++; -} - -#define EIGEN_DENSE_STORAGE_CTOR_PLUGIN { on_temporary_creation(size); } +#define TEST_ENABLE_TEMPORARY_TRACKING #include "main.h" -#define VERIFY_EVALUATION_COUNT(XPR,N) {\ - nb_temporaries = 0; \ - XPR; \ - if(nb_temporaries!=N) std::cerr << "nb_temporaries == " << nb_temporaries << "\n"; \ - VERIFY( (#XPR) && nb_temporaries==N ); \ - } - - // test Ref.h template<typename MatrixType> void ref_matrix(const MatrixType& m) |