define QVERIFY_EXCEPTION_THROWN if it's not exist

This commit is contained in:
mutouyun 2018-12-17 13:44:48 +08:00
parent 245964f13d
commit a5580b915e

View File

@ -320,6 +320,30 @@ void Unit::test_prod_cons_performance() {
test_prod_cons <3 , 3 >(); // test & verify
}
#ifndef QVERIFY_EXCEPTION_THROWN
#define QVERIFY_EXCEPTION_THROWN(expression, exceptiontype) \
do {\
QT_TRY {\
QT_TRY {\
expression;\
QTest::qFail("Expected exception of type " #exceptiontype " to be thrown" \
" but no exception caught", __FILE__, __LINE__);\
return;\
} QT_CATCH (const exceptiontype &) {\
}\
} QT_CATCH (const std::exception &e) {\
QByteArray msg = QByteArray() + "Expected exception of type " #exceptiontype \
" to be thrown but std::exception caught with message: " + e.what(); \
QTest::qFail(msg.constData(), __FILE__, __LINE__);\
return;\
} QT_CATCH (...) {\
QTest::qFail("Expected exception of type " #exceptiontype " to be thrown" \
" but unknown exception caught", __FILE__, __LINE__);\
return;\
}\
} while (false)
#endif/*!QVERIFY_EXCEPTION_THROWN*/
void Unit::test_queue() {
ipc::circ::queue<msg_t> queue;
queue.push(1, 2);