diff options
author | Christoph Hertzberg <chtz@informatik.uni-bremen.de> | 2014-07-22 13:16:44 +0200 |
---|---|---|
committer | Christoph Hertzberg <chtz@informatik.uni-bremen.de> | 2014-07-22 13:16:44 +0200 |
commit | a8283e0ed2d3e42ba8e1c42f51cb08eacc301047 (patch) | |
tree | c9c78db74cdb680132a8779db69cf53ee73390ba /test/ctorleak.cpp | |
parent | 529e6cb5529f626b7c5cf781bdcd5a5720f904c1 (diff) |
Define EIGEN_TRY, EIGEN_CATCH, EIGEN_THROW as suggested by Moritz Klammer.
Make it possible to run unit-tests with exceptions disabled via EIGEN_TEST_NO_EXCEPTIONS flag.
Enhanced ctorleak unit-test
Diffstat (limited to 'test/ctorleak.cpp')
-rw-r--r-- | test/ctorleak.cpp | 40 |
1 files changed, 11 insertions, 29 deletions
diff --git a/test/ctorleak.cpp b/test/ctorleak.cpp index f3f4411c8..145d91be4 100644 --- a/test/ctorleak.cpp +++ b/test/ctorleak.cpp @@ -28,42 +28,24 @@ struct Foo unsigned Foo::object_count = 0; unsigned Foo::object_limit = 0; -namespace Eigen -{ - template<> - struct NumTraits<Foo> - { - typedef double Real; - typedef double NonInteger; - typedef double Nested; - enum - { - IsComplex = 0, - IsInteger = 1, - ReadCost = -1, - AddCost = -1, - MulCost = -1, - IsSigned = 1, - RequireInitialization = 1 - }; - static inline Real epsilon() { return 1.0; } - static inline Real dummy_epsilon() { return 0.0; } - }; -} void test_ctorleak() { + typedef DenseIndex Index; Foo::object_count = 0; - Foo::object_limit = internal::random(0, 14 * 92 - 2); + for(int i = 0; i < g_repeat; i++) { + Index rows = internal::random<Index>(2,EIGEN_TEST_MAX_SIZE), cols = internal::random<Index>(2,EIGEN_TEST_MAX_SIZE); + Foo::object_limit = internal::random(0, rows*cols - 2); #ifdef EIGEN_EXCEPTIONS - try -#endif + try { - Matrix<Foo, Dynamic, Dynamic> m(14, 92); - eigen_assert(false); // not reached - } +#endif + Matrix<Foo, Dynamic, Dynamic> m(rows, cols); #ifdef EIGEN_EXCEPTIONS - catch (const Foo::Fail&) { /* ignore */ } + VERIFY(false); // not reached if exceptions are enabled + } + catch (const Foo::Fail&) { /* ignore */ } #endif + } VERIFY_IS_EQUAL(static_cast<unsigned>(0), Foo::object_count); } |