From 35ec6283dc4741b39b0e3c32a7b9abe68c736b78 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 1 Feb 2022 15:32:55 +0100 Subject: Convert some QVERIFY2() with useless messages to QVERIFY() Telling us the condition tested should have been true is what QVERIFY() does anyway, so don't go to the whole trouble of saying the same thing - and wrapping it in in a QString() merely in order to then qPrintable() it back out again, pointlessly converting a C-string to unicode and back again. At the same time, skip one other qPrintable(QString("...")) without .arg() formatting; and change the check it's the message for to use QL1S::arg() instead of QString::arg(). Change-Id: Ie71a79da8017916d301a38b69fc422e55a5a3649 Reviewed-by: Marc Mutz --- tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp') diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp index 0fcee19dba..8d2183512c 100644 --- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp @@ -3045,21 +3045,18 @@ void tst_QSqlQuery::queryOnInvalidDatabase() QRegularExpression("QSqlDatabase: available drivers: ")); #endif QSqlDatabase db = QSqlDatabase::addDatabase( "INVALID", "invalidConnection" ); - QVERIFY2( db.lastError().isValid(), - qPrintable( QString( "db.lastError().isValid() should be true!" ) ) ); + QVERIFY(db.lastError().isValid()); QTest::ignoreMessage( QtWarningMsg, "QSqlQuery::exec: database not open" ); QSqlQuery query( "SELECT 1 AS ID", db ); - QVERIFY2( query.lastError().isValid(), - qPrintable( QString( "query.lastError().isValid() should be true!" ) ) ); + QVERIFY(query.lastError().isValid()); } { QSqlDatabase db = QSqlDatabase::database( "this connection does not exist" ); QTest::ignoreMessage( QtWarningMsg, "QSqlQuery::exec: database not open" ); QSqlQuery query( "SELECT 1 AS ID", db ); - QVERIFY2( query.lastError().isValid(), - qPrintable( QString( "query.lastError().isValid() should be true!" ) ) ); + QVERIFY(query.lastError().isValid()); } } @@ -3091,8 +3088,8 @@ void tst_QSqlQuery::createQueryOnClosedDatabase() QCOMPARE( q.value( 2 ).toString().trimmed(), QLatin1String( "Char1" ) ); db.close(); - QVERIFY2( !q.exec( QString( "select * from %1 where id = 1" ).arg( qtest ) ), - qPrintable( QString( "This can't happen! The query should not have been executed!" ) ) ); + QVERIFY2(!q.exec(QLatin1String("select * from %1 where id = 1").arg(qtest)), + "This can't happen! The query should not have been executed!"); } void tst_QSqlQuery::reExecutePreparedForwardOnlyQuery() -- cgit v1.2.3