From f28ba2be974eab5397f6b9d554c3a56b01fed33c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 6 May 2012 14:48:46 -0700 Subject: Fix encoding mismatches in tst_QSqlQuery MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The file has been UTF-8 encoded for years, which means that the line: QString longerBLOB( "abcdefghijklmnopqrstuvxyz¿äëïöü¡ " ); Loaded a mojibake into QString. Then, this data was stored as a blob in the database by calling longerBLOB.toLatin1() (a QByteArray), and reloaded for check using toString(). Once the QString default codec changes to UTF-8, the mojibake would get fixed, and the test would fail. Make sure it doesn't happen. Change-Id: If12d6124c973e4a1c1b7978d90fffb9aa5545c66 Reviewed-by: Lars Knoll --- tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp index f5cc8d3b02..b5fb36a62b 100644 --- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp @@ -2712,11 +2712,11 @@ void tst_QSqlQuery::blobsPreparedQuery() QVERIFY_SQL( q, exec( QString( "CREATE TABLE %1(id INTEGER, data %2)" ).arg( tableName ).arg( typeName ) ) ); q.prepare( QString( "INSERT INTO %1(id, data) VALUES(:id, :data)" ).arg( tableName ) ); q.bindValue( ":id", 1 ); - q.bindValue( ":data", shortBLOB.toLatin1() ); + q.bindValue( ":data", shortBLOB ); QVERIFY_SQL( q, exec() ); q.bindValue( ":id", 2 ); - q.bindValue( ":data", longerBLOB.toLatin1() ); + q.bindValue( ":data", longerBLOB ); QVERIFY_SQL( q, exec() ); // Two executions and result sets @@ -2729,7 +2729,7 @@ void tst_QSqlQuery::blobsPreparedQuery() q.bindValue( 0, QVariant( 2 ) ); QVERIFY_SQL( q, exec() ); QVERIFY_SQL( q, next() ); - QCOMPARE( q.value( 0 ).toString(), longerBLOB ); + QCOMPARE( q.value( 0 ).toString().toUtf8(), longerBLOB.toUtf8() ); // Only one execution and result set q.prepare( QString( "SELECT id, data FROM %1 ORDER BY id" ).arg( tableName ) ); -- cgit v1.2.3