Make regression callback cleanup safe after failed assertions
This commit is contained in:
1 parent
58c2b5644d
commit
73a5366f1c
2 files changed
+5
-1
No files matched your search
@@ -29,6 +29,8 @@ extern "C" {
|
||||
#include <QVBoxLayout>
|
||||
#include <QStringListModel>
|
||||
#include <QScrollBar>
|
||||
#include <QPointer>
|
||||
#include <QScopeGuard>
|
||||
|
||||
static QString makeFile(const QTemporaryDir& dir, const QString& name, const QByteArray& contents = "test") {
|
||||
const QString path = dir.filePath(name);
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <thread>
|
||||
#include <future>
|
||||
#include <QPointer>
|
||||
#include <QScopeGuard>
|
||||
|
||||
#ifdef UTUN_TEST_BRIDGE_ALLOC_FAILURES
|
||||
static int failAllocation;
|
||||
@@ -214,6 +215,7 @@ private slots:
|
||||
|
||||
void cancelledSubmissionReturnsOneFailureAndFreesRequest() {
|
||||
BoundCore core; QVERIFY(core.ua); core.attach(); submitted.clear();
|
||||
const auto resetCallback = qScopeGuard([] { gui_bridge_set_msg_submitted_cb(nullptr); });
|
||||
gui_bridge_set_msg_submitted_cb([](const uint8_t* data, int len) { submitted.append(QByteArray((const char*)data, len)); });
|
||||
const size_t before = u_get_allocated_count();
|
||||
auto* request = static_cast<chat_msg_submit*>(u_calloc(1, sizeof(chat_msg_submit))); QVERIFY(request);
|
||||
@@ -222,7 +224,7 @@ private slots:
|
||||
QCoreApplication::processEvents();
|
||||
QCOMPARE(submitted, QList<QByteArray>({QByteArray::fromHex("080706050403020100")}));
|
||||
uasync_poll(core.ua, 0); QCoreApplication::processEvents(); QCOMPARE(submitted.size(), 1);
|
||||
QCOMPARE(u_get_allocated_count(), before); gui_bridge_set_msg_submitted_cb(nullptr);
|
||||
QCOMPARE(u_get_allocated_count(), before);
|
||||
}
|
||||
|
||||
void invalidPostArgumentsDoNotTurnIntoEmptyEvents() {
|
||||
|
||||
Reference in new issue
Block a user