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
@ -1020,12 +1020,16 @@ void tst_QSqlQuery::blob()
|
|||||||
QVERIFY( q.next() );
|
QVERIFY( q.next() );
|
||||||
QByteArray res = q.value( 1 ).toByteArray();
|
QByteArray res = q.value( 1 ).toByteArray();
|
||||||
QVERIFY2(res.size() >= ba.size(),
|
QVERIFY2(res.size() >= ba.size(),
|
||||||
QString( "array sizes differ, expected %1, got %2" ).arg( ba.size() ).arg( res.size() ).toLatin1() );
|
qPrintable(QString::asprintf(
|
||||||
|
"array sizes differ, expected (at least) %" PRIdQSIZETYPE
|
||||||
|
", got %" PRIdQSIZETYPE, ba.size(), res.size())));
|
||||||
|
|
||||||
for (int i2 = 0; i2 < ba.size(); ++i2) {
|
for (int i2 = 0; i2 < ba.size(); ++i2) {
|
||||||
if ( res[i2] != ba[i2] )
|
if (res[i2] != ba[i2]) {
|
||||||
QFAIL( QString( "ByteArrays differ at position %1, expected %2, got %3" ).arg(
|
QFAIL(qPrintable(QString::asprintf(
|
||||||
i2 ).arg(( int )( unsigned char )ba[i2] ).arg(( int )( unsigned char )res[i2] ).toLatin1() );
|
"ByteArrays differ at position %d, expected %hhu, got %hhu",
|
||||||
|
i2, ba[i2], res[i2])));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user