mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-06 16:56:45 +08:00
define QVERIFY_EXCEPTION_THROWN if it's not exist
This commit is contained in:
parent
245964f13d
commit
a5580b915e
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user