summaryrefslogtreecommitdiffstats
path: root/tests/auto/sql/kernel
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2022-02-08 13:10:47 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2022-02-17 15:51:30 +0100
commit203f4b93cf17c9a9942c9a2ce6de6bf1d1d3287b (patch)
tree0819fc7788ac3f24118762f4372f29678297b268 /tests/auto/sql/kernel
parente63b3b48acb326a2251e317e61e481843fa65bcd (diff)
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>
Diffstat (limited to 'tests/auto/sql/kernel')
-rw-r--r--tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
index c248ab24c7..d33dcbfe7f 100644
--- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
@@ -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])));
+ }
}
}
}