Invert a condition to save a lot of indentation

Simply if (!condition) QSKIP(...) instead of having a long block
depend on the condition with the QSKIP() in its else block (which
should have had braces, as it was).

While dedenting the code block, tidied up spacing: only include blank
lines where they break up the code into blocks that go together, don't
leave spaces just inside parentheses.

Change-Id: I0196150088be88a7c6073b997a315b8f14d5f392
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
Edward Welbourne 2022-02-01 14:54:03 +01:00
parent b3f67d2ba3
commit 426f032119

View File

@ -494,9 +494,11 @@ void tst_QSqlQuery::char1SelectUnicode()
if (dbType == QSqlDriver::DB2) if (dbType == QSqlDriver::DB2)
QSKIP("Needs someone with more Unicode knowledge than I have to fix"); QSKIP("Needs someone with more Unicode knowledge than I have to fix");
if ( db.driver()->hasFeature( QSqlDriver::Unicode ) ) { if (!db.driver()->hasFeature(QSqlDriver::Unicode))
QString uniStr( QChar(0x0915) ); // DEVANAGARI LETTER KA QSKIP("Database not unicode capable");
QSqlQuery q( db );
QString uniStr(QChar(0x0915)); // DEVANAGARI LETTER KA
QSqlQuery q(db);
QLatin1String createQuery; QLatin1String createQuery;
const QString char1SelectUnicode(qTableName("char1SU", __FILE__, db)); const QString char1SelectUnicode(qTableName("char1SU", __FILE__, db));
@ -513,8 +515,7 @@ void tst_QSqlQuery::char1SelectUnicode()
createQuery = QLatin1String("create table %1 (id char(1) character set unicode_fss)"); createQuery = QLatin1String("create table %1 (id char(1) character set unicode_fss)");
break; break;
case QSqlDriver::MySqlServer: case QSqlDriver::MySqlServer:
createQuery = createQuery = QLatin1String("create table %1 (id char(1)) default character set 'utf8'");
QLatin1String("create table %1 (id char(1)) default character set 'utf8'");
break; break;
default: default:
createQuery = QLatin1String("create table %1 (id char(1))"); createQuery = QLatin1String("create table %1 (id char(1))");
@ -524,19 +525,16 @@ void tst_QSqlQuery::char1SelectUnicode()
QVERIFY_SQL(q, exec(createQuery.arg(char1SelectUnicode))); QVERIFY_SQL(q, exec(createQuery.arg(char1SelectUnicode)));
QVERIFY_SQL(q, prepare(QLatin1String("insert into %1 values(?)").arg(char1SelectUnicode))); QVERIFY_SQL(q, prepare(QLatin1String("insert into %1 values(?)").arg(char1SelectUnicode)));
q.bindValue( 0, uniStr ); q.bindValue(0, uniStr);
QVERIFY_SQL( q, exec() ); QVERIFY_SQL(q, exec());
QVERIFY_SQL( q, exec( "select * from " + char1SelectUnicode ) ); QVERIFY_SQL(q, exec("select * from " + char1SelectUnicode));
QVERIFY( q.next() ); QVERIFY(q.next());
if ( !q.value( 0 ).toString().isEmpty() ) if (!q.value(0).toString().isEmpty())
QCOMPARE( q.value( 0 ).toString()[ 0 ].unicode(), uniStr[0].unicode() ); QCOMPARE(q.value(0).toString()[0].unicode(), uniStr[0].unicode());
QCOMPARE( q.value( 0 ).toString().trimmed(), uniStr ); QCOMPARE(q.value(0).toString().trimmed(), uniStr);
QVERIFY( !q.next() ); QVERIFY(!q.next());
}
else
QSKIP( "Database not unicode capable");
} }
void tst_QSqlQuery::oraRowId() void tst_QSqlQuery::oraRowId()