From a8283e0ed2d3e42ba8e1c42f51cb08eacc301047 Mon Sep 17 00:00:00 2001 From: Christoph Hertzberg Date: Tue, 22 Jul 2014 13:16:44 +0200 Subject: 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 --- test/ctorleak.cpp | 40 +++++++++++----------------------------- 1 file changed, 11 insertions(+), 29 deletions(-) (limited to 'test/ctorleak.cpp') 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 - { - 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(2,EIGEN_TEST_MAX_SIZE), cols = internal::random(2,EIGEN_TEST_MAX_SIZE); + Foo::object_limit = internal::random(0, rows*cols - 2); #ifdef EIGEN_EXCEPTIONS - try -#endif + try { - Matrix m(14, 92); - eigen_assert(false); // not reached - } +#endif + Matrix 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(0), Foo::object_count); } -- cgit v1.2.3