Fix test to pass with QT_FORCE_ASSERTS

Add QT_FORCE_ASSERTS to condition with standard comment.

Pick-to: 6.3 6.2
Change-Id: If493c7cdea8164f010228a755915a211c1cf1b39
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Friedemann Kleint 2022-02-18 14:12:06 +01:00
parent 72e1fc7c0b
commit 1af068332b
2 changed files with 5 additions and 3 deletions

View File

@ -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");

View File

@ -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