Prefer QString::asprintf() over QString::arg when formatting numbers
Marc alleges it is more efficient. Corrected part of a message to be more accurate in the process. Save some casting by using suitable format specifiers. Change-Id: Ic31a4e17b8910d35781a494ec860c7a08f08f33b Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
parent
e63b3b48ac
commit
203f4b93cf
@ -1019,13 +1019,17 @@ void tst_QSqlQuery::blob()
|
||||
for (int i = 0; i < BLOBCOUNT; ++i) {
|
||||
QVERIFY( q.next() );
|
||||
QByteArray res = q.value( 1 ).toByteArray();
|
||||
QVERIFY2( res.size() >= ba.size(),
|
||||
QString( "array sizes differ, expected %1, got %2" ).arg( ba.size() ).arg( res.size() ).toLatin1() );
|
||||
QVERIFY2(res.size() >= ba.size(),
|
||||
qPrintable(QString::asprintf(
|
||||
"array sizes differ, expected (at least) %" PRIdQSIZETYPE
|
||||
", got %" PRIdQSIZETYPE, ba.size(), res.size())));
|
||||
|
||||
for (int i2 = 0; i2 < ba.size(); ++i2) {
|
||||
if ( res[i2] != ba[i2] )
|
||||
QFAIL( QString( "ByteArrays differ at position %1, expected %2, got %3" ).arg(
|
||||
i2 ).arg(( int )( unsigned char )ba[i2] ).arg(( int )( unsigned char )res[i2] ).toLatin1() );
|
||||
if (res[i2] != ba[i2]) {
|
||||
QFAIL(qPrintable(QString::asprintf(
|
||||
"ByteArrays differ at position %d, expected %hhu, got %hhu",
|
||||
i2, ba[i2], res[i2])));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user