mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-10 18:59:01 +08:00
small fix of VERIFY_ASSERT in debug mode
This commit is contained in:
parent
afc64f3332
commit
908a0fbab5
54
test/main.h
54
test/main.h
@ -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
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user