Prefer QFAIL("Informative message") over QVERIFY(false)

Change-Id: I706b0aedfa870452331a8c2c488d55b279ee452a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Edward Welbourne 2021-06-11 14:38:24 +02:00
parent d2a4a5e601
commit accdfbb396
7 changed files with 23 additions and 24 deletions

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@ -168,7 +168,7 @@ void tst_QFlags::constExpr()
case Qt::LeftButton: QVERIFY(false); break;
case Qt::RightButton: QVERIFY(false); break;
case int(Qt::LeftButton | Qt::RightButton): QVERIFY(true); break;
default: QVERIFY(false);
default: QFAIL(qPrintable(QStringLiteral("Unexpected button: %1").arg(btn)));
}
QVERIFY(verifyConstExpr<uint((Qt::LeftButton | Qt::RightButton) & Qt::LeftButton)>(Qt::LeftButton));

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@ -956,13 +956,13 @@ void tst_QtJson::testObjectIteration()
QJsonObject object;
for (QJsonObject::iterator it = object.begin(); it != object.end(); ++it)
QVERIFY(false);
QFAIL("Iterator of default-initialized object should be empty");
const QString property = "kkk";
object.insert(property, 11);
object.take(property);
for (QJsonObject::iterator it = object.begin(); it != object.end(); ++it)
QVERIFY(false);
QFAIL("Iterator after property add-and-remove should be empty");
for (int i = 0; i < 10; ++i)
object[QString::number(i)] = (double)i;

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2019 The Qt Company Ltd.
** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@ -101,7 +101,7 @@ void tst_QShader::simpleCompileCheckResults()
QCOMPARE(v.type, QShaderDescription::Vec3);
break;
default:
QVERIFY(false);
QFAIL(qPrintable(QStringLiteral("Bad location: %1").arg(v.location)));
break;
}
}
@ -113,7 +113,7 @@ void tst_QShader::simpleCompileCheckResults()
QCOMPARE(v.type, QShaderDescription::Vec3);
break;
default:
QVERIFY(false);
QFAIL(qPrintable(QStringLiteral("Bad location: %1").arg(v.location)));
break;
}
}
@ -142,7 +142,7 @@ void tst_QShader::simpleCompileCheckResults()
QCOMPARE(v.type, QShaderDescription::Float);
break;
default:
QVERIFY(false);
QFAIL(qPrintable(QStringLiteral("Too many blocks: %1").arg(blk.members.count())));
break;
}
}
@ -409,7 +409,7 @@ void tst_QShader::loadV4()
QCOMPARE(v.type, QShaderDescription::Vec2);
break;
default:
QVERIFY(false);
QFAIL(qPrintable(QStringLiteral("Bad location: %1").arg(v.location)));
break;
}
}
@ -421,7 +421,7 @@ void tst_QShader::loadV4()
QCOMPARE(v.type, QShaderDescription::Vec4);
break;
default:
QVERIFY(false);
QFAIL(qPrintable(QStringLiteral("Bad location: %1").arg(v.location)));
break;
}
}
@ -450,7 +450,7 @@ void tst_QShader::loadV4()
QCOMPARE(v.type, QShaderDescription::Float);
break;
default:
QVERIFY(false);
QFAIL(qPrintable(QStringLiteral("Bad many blocks: %1").arg(blk.members.count())));
break;
}
}

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@ -6539,8 +6539,7 @@ void tst_QNetworkReply::abortOnEncrypted()
server.connect(&server, &SslServer::newEncryptedConnection, [&server]() {
// MSVC 201X C4573-misunderstands connect() or QObject::connect(), so use server.connect():
server.connect(server.socket, &QTcpSocket::readyRead, server.socket, []() {
// This slot must not be invoked!
QVERIFY(false);
QFAIL("This slot must not be invoked!");
});
});

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@ -438,7 +438,7 @@ void tst_QListView::cursorMove()
}
break;
default:
QVERIFY(false);
QFAIL(qPrintable(QStringLiteral("Unexpected key: %1").arg(key)));
}
QCoreApplication::processEvents();

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@ -1878,7 +1878,7 @@ void tst_QTreeView::keyboardNavigation()
}
break;
default:
QVERIFY(false);
QFAIL(qPrintable(QStringLiteral("Unexpected key: %1").arg(key)));
}
QCOMPARE(view.currentIndex().row(), row);

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@ -1540,7 +1540,7 @@ void tst_QTreeWidget::keyboardNavigation()
}
break;
default:
QVERIFY(false);
QFAIL(qPrintable(QStringLiteral("Unexpected key: %1").arg(key)));
}
QTreeWidgetItem *current = testWidget->currentItem();