diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2021-06-11 14:38:24 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2021-06-14 15:57:16 +0200 |
commit | accdfbb396ee7f1345ce33929dd57c5a571d36f5 (patch) | |
tree | 3247003d6346016601ff07db003aea043fe052fa /tests | |
parent | d2a4a5e60162bb66558ab483679b1943c11caa8b (diff) |
Prefer QFAIL("Informative message") over QVERIFY(false)
Change-Id: I706b0aedfa870452331a8c2c488d55b279ee452a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests')
7 files changed, 23 insertions, 24 deletions
diff --git a/tests/auto/corelib/global/qflags/tst_qflags.cpp b/tests/auto/corelib/global/qflags/tst_qflags.cpp index 4201293258..3179cfc9d2 100644 --- a/tests/auto/corelib/global/qflags/tst_qflags.cpp +++ b/tests/auto/corelib/global/qflags/tst_qflags.cpp @@ -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. @@ -165,10 +165,10 @@ void tst_QFlags::constExpr() { Qt::MouseButtons btn = Qt::LeftButton | Qt::RightButton; switch (btn) { - case Qt::LeftButton: QVERIFY(false); break; - case Qt::RightButton: QVERIFY(false); break; - case int(Qt::LeftButton | Qt::RightButton): QVERIFY(true); break; - default: QVERIFY(false); + case Qt::LeftButton: QVERIFY(false); break; + case Qt::RightButton: QVERIFY(false); break; + case int(Qt::LeftButton | Qt::RightButton): QVERIFY(true); break; + default: QFAIL(qPrintable(QStringLiteral("Unexpected button: %1").arg(btn))); } QVERIFY(verifyConstExpr<uint((Qt::LeftButton | Qt::RightButton) & Qt::LeftButton)>(Qt::LeftButton)); diff --git a/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/tests/auto/corelib/serialization/json/tst_qtjson.cpp index afd3303298..60dfc3e713 100644 --- a/tests/auto/corelib/serialization/json/tst_qtjson.cpp +++ b/tests/auto/corelib/serialization/json/tst_qtjson.cpp @@ -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; diff --git a/tests/auto/gui/rhi/qshader/tst_qshader.cpp b/tests/auto/gui/rhi/qshader/tst_qshader.cpp index 1a57daf220..1b3d861756 100644 --- a/tests/auto/gui/rhi/qshader/tst_qshader.cpp +++ b/tests/auto/gui/rhi/qshader/tst_qshader.cpp @@ -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; } } diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 0930dd2097..7e3251476e 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -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!"); }); }); diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp index 38c34aab76..b5c938cff8 100644 --- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp +++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp @@ -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(); diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index 579c2d234f..0d6d80ad59 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -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); diff --git a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp index 4cfea81572..a60d09ec0d 100644 --- a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp +++ b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp @@ -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(); |