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 <marc.mutz@qt.io>
This commit is contained in:
parent
3253037329
commit
35ec6283dc
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user