small fix of VERIFY_ASSERT in debug mode

This commit is contained in:
Gael Guennebaud 2008-03-13 09:51:18 +00:00
parent afc64f3332
commit 908a0fbab5

View File

@ -73,31 +73,47 @@
static std::vector<std::string> ei_assert_list; static std::vector<std::string> ei_assert_list;
} }
#define assert(a) if (!(a)) { throw Eigen::ei_assert_exception();} \ #define assert(a) \
else if (Eigen::ei_push_assert) {ei_assert_list.push_back( std::string(EI_PP_MAKE_STRING(__FILE__)" ("EI_PP_MAKE_STRING(__LINE__)") : "#a) );} if( (!(a)) && (!no_more_assert) ) \
{ \
Eigen::no_more_assert = true; \
throw Eigen::ei_assert_exception(); \
} \
else if (Eigen::ei_push_assert) \
{ \
ei_assert_list.push_back(std::string(EI_PP_MAKE_STRING(__FILE__)" ("EI_PP_MAKE_STRING(__LINE__)") : "#a) ); \
}
#define VERIFY_RAISES_ASSERT(a) {\ #define VERIFY_RAISES_ASSERT(a) \
try { \ { \
Eigen::ei_assert_list.clear(); \ try { \
Eigen::ei_push_assert = true; \ Eigen::ei_assert_list.clear(); \
a; \ Eigen::ei_push_assert = true; \
Eigen::ei_push_assert = false; \ a; \
std::cout << "One of the following asserts should have been raised:\n"; \ Eigen::ei_push_assert = false; \
for (uint ai=0 ; ai<ei_assert_list.size() ; ++ai) \ std::cout << "One of the following asserts should have been raised:\n"; \
std::cout << " " << ei_assert_list[ai] << "\n"; \ for (uint ai=0 ; ai<ei_assert_list.size() ; ++ai) \
QVERIFY(Eigen::should_raise_an_assert && # a); \ std::cout << " " << ei_assert_list[ai] << "\n"; \
} catch (Eigen::ei_assert_exception e) { Eigen::ei_push_assert = false; QVERIFY(true);} } QVERIFY(Eigen::should_raise_an_assert && # a); \
} catch (Eigen::ei_assert_exception e) { \
Eigen::ei_push_assert = false; QVERIFY(true); \
} \
}
#else // EIGEN_DEBUG_ASSERTS #else // EIGEN_DEBUG_ASSERTS
#define assert(a) if( (!(a)) && (!no_more_assert) ) { \ #define assert(a) \
Eigen::no_more_assert = true; \ if( (!(a)) && (!no_more_assert) ) \
throw Eigen::ei_assert_exception(""); \ { \
Eigen::no_more_assert = true; \
throw Eigen::ei_assert_exception(); \
} }
#define VERIFY_RAISES_ASSERT(a) {\ #define VERIFY_RAISES_ASSERT(a) \
try { a; QVERIFY(Eigen::should_raise_an_assert && # a); } \ { \
catch (Eigen::ei_assert_exception e) { QVERIFY(true);} } try { a; QVERIFY(Eigen::should_raise_an_assert && # a); } \
catch (Eigen::ei_assert_exception e) { QVERIFY(true); } \
}
#endif // EIGEN_DEBUG_ASSERTS #endif // EIGEN_DEBUG_ASSERTS