From 1af068332bd8a834ae684cfa8c586f71f7e7bd28 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 18 Feb 2022 14:12:06 +0100 Subject: [PATCH] Fix test to pass with QT_FORCE_ASSERTS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add QT_FORCE_ASSERTS to condition with standard comment. Pick-to: 6.3 6.2 Change-Id: If493c7cdea8164f010228a755915a211c1cf1b39 Reviewed-by: MÃ¥rten Nordheim --- .../qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp | 3 ++- .../widgets/qabstractspinbox/tst_qabstractspinbox.cpp | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp index f07d324ce1..35d82291a6 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp @@ -3197,7 +3197,8 @@ void tst_QSortFilterProxyModel::mapFromToSource() QCOMPARE(proxy.mapFromSource(QModelIndex()), QModelIndex()); QCOMPARE(proxy.mapToSource(QModelIndex()), QModelIndex()); -#ifdef QT_NO_DEBUG //if Qt is compiled in debug mode, this will assert + // Will assert in debug, so only test in release +#if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) QTest::ignoreMessage(QtWarningMsg, "QSortFilterProxyModel: index from wrong model passed to mapToSource"); QCOMPARE(proxy.mapToSource(source.index(2, 3)), QModelIndex()); QTest::ignoreMessage(QtWarningMsg, "QSortFilterProxyModel: index from wrong model passed to mapFromSource"); diff --git a/tests/auto/widgets/widgets/qabstractspinbox/tst_qabstractspinbox.cpp b/tests/auto/widgets/widgets/qabstractspinbox/tst_qabstractspinbox.cpp index 6898cf18dc..23effb60a5 100644 --- a/tests/auto/widgets/widgets/qabstractspinbox/tst_qabstractspinbox.cpp +++ b/tests/auto/widgets/widgets/qabstractspinbox/tst_qabstractspinbox.cpp @@ -115,8 +115,9 @@ void tst_QAbstractSpinBox::getSetCheck() QLineEdit *var3 = new QLineEdit(0); obj1.setLineEdit(var3); QCOMPARE(var3, obj1.lineEdit()); -#ifndef QT_DEBUG - obj1.setLineEdit((QLineEdit *)0); // Will assert in debug, so only test in release + // Will assert in debug, so only test in release +#if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) + obj1.setLineEdit(nullptr); QCOMPARE(var3, obj1.lineEdit()); // Setting 0 should keep the current editor #endif // delete var3; // No delete, since QAbstractSpinBox takes ownership