summaryrefslogtreecommitdiffstats
path: root/tests/auto/sql
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-10-13 09:46:56 +0200
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-10-13 18:14:27 +0000
commita2a00eb044596f3e3f628b6b20b38a5ba524915c (patch)
treeefcf26def4cdf70e95134ba9b86b561346646862 /tests/auto/sql
parente86f889de7a38208d0cb0a8ca4cd1fb027894b3c (diff)
Tests: Fix single-character string literals.
Use character literals where applicable. Change-Id: I1a026c320079ee5ca6f70be835d5a541deee2dd1 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'tests/auto/sql')
-rw-r--r--tests/auto/sql/kernel/qsqldatabase/tst_databases.h14
-rw-r--r--tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp2
-rw-r--r--tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp2
-rw-r--r--tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp20
-rw-r--r--tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp16
-rw-r--r--tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp2
6 files changed, 28 insertions, 28 deletions
diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_databases.h b/tests/auto/sql/kernel/qsqldatabase/tst_databases.h
index fe8a3689b0..3ba4833dd5 100644
--- a/tests/auto/sql/kernel/qsqldatabase/tst_databases.h
+++ b/tests/auto/sql/kernel/qsqldatabase/tst_databases.h
@@ -119,7 +119,7 @@ inline static QString qTableName(const QString& prefix, QSqlDatabase db)
QString tableStr;
if (db.driverName().toLower().contains("ODBC"))
tableStr += QLatin1String("_odbc");
- return fixupTableName(QString(db.driver()->escapeIdentifier(prefix + tableStr + "_" +
+ return fixupTableName(QString(db.driver()->escapeIdentifier(prefix + tableStr + QLatin1Char('_') +
qGetHostName(), QSqlDriver::TableName)),db);
}
@@ -219,12 +219,12 @@ public:
}
// construct a stupid unique name
- QString cName = QString::number( counter++ ) + "_" + driver + "@";
+ QString cName = QString::number( counter++ ) + QLatin1Char('_') + driver + QLatin1Char('@');
cName += host.isEmpty() ? dbName : host;
if ( port > 0 )
- cName += ":" + QString::number( port );
+ cName += QLatin1Char(':') + QString::number( port );
db = QSqlDatabase::addDatabase( driver, cName );
@@ -364,7 +364,7 @@ public:
// for debugging only: outputs the connection as string
static QString dbToString( const QSqlDatabase db )
{
- QString res = db.driverName() + "@";
+ QString res = db.driverName() + QLatin1Char('@');
if ( db.driverName().startsWith( "QODBC" ) || db.driverName().startsWith( "QOCI" ) ) {
res += db.databaseName();
@@ -373,7 +373,7 @@ public:
}
if ( db.port() > 0 ) {
- res += ":" + QString::number( db.port() );
+ res += QLatin1Char(':') + QString::number( db.port() );
}
return res;
@@ -522,7 +522,7 @@ public:
result += '\'';
if(!err.driverText().isEmpty())
result += err.driverText() + "' || '";
- result += err.databaseText() + "'";
+ result += err.databaseText() + QLatin1Char('\'');
return result.toLocal8Bit();
}
@@ -534,7 +534,7 @@ public:
result += '\'';
if(!err.driverText().isEmpty())
result += err.driverText() + "' || '";
- result += err.databaseText() + "'";
+ result += err.databaseText() + QLatin1Char('\'');
return result.toLocal8Bit();
}
diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp
index 83cf0394f9..5738f20f15 100644
--- a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp
+++ b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp
@@ -217,7 +217,7 @@ struct FieldDef {
{
QString rt = typeName;
rt.replace(QRegExp("\\s"), QString("_"));
- int i = rt.indexOf("(");
+ int i = rt.indexOf(QLatin1Char('('));
if (i == -1)
i = rt.length();
if (i > 20)
diff --git a/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp b/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp
index 2f48b65e74..5273632138 100644
--- a/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp
+++ b/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp
@@ -79,7 +79,7 @@ void tst_QSqlDriver::recreateTestTables(QSqlDatabase db)
tst_Databases::safeDropTable( db, relTEST1 );
QString doubleField = (dbType == QSqlDriver::SQLite) ? "more_data double" : "more_data double(8,7)";
QVERIFY_SQL( q, exec("create table " + relTEST1 +
- " (id int not null primary key, name varchar(20), title_key int, another_title_key int, " + doubleField + ")"));
+ " (id int not null primary key, name varchar(20), title_key int, another_title_key int, " + doubleField + QLatin1Char(')')));
QVERIFY_SQL( q, exec("insert into " + relTEST1 + " values(1, 'harry', 1, 2, 1.234567)"));
QVERIFY_SQL( q, exec("insert into " + relTEST1 + " values(2, 'trond', 2, 1, 8.901234)"));
QVERIFY_SQL( q, exec("insert into " + relTEST1 + " values(3, 'vohi', 1, 2, 5.678901)"));
diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
index b98ab68ae9..6311e4c480 100644
--- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
@@ -959,14 +959,14 @@ void tst_QSqlQuery::value()
if (dbType == QSqlDriver::Interbase)
QVERIFY( q.value( 1 ).toString().startsWith( "VarChar" + QString::number( i ) ) );
- else if ( q.value( 1 ).toString().right( 1 ) == " " )
+ else if ( q.value( 1 ).toString().endsWith(QLatin1Char(' ')))
QCOMPARE( q.value( 1 ).toString(), ( "VarChar" + QString::number( i ) + " " ) );
else
QCOMPARE( q.value( 1 ).toString(), ( "VarChar" + QString::number( i ) ) );
if (dbType == QSqlDriver::Interbase)
QVERIFY( q.value( 2 ).toString().startsWith( "Char" + QString::number( i ) ) );
- else if ( q.value( 2 ).toString().right( 1 ) != " " )
+ else if (!q.value( 2 ).toString().endsWith(QLatin1Char(' ')))
QCOMPARE( q.value( 2 ).toString(), ( "Char" + QString::number( i ) ) );
else
QCOMPARE( q.value( 2 ).toString(), ( "Char" + QString::number( i ) + " " ) );
@@ -3145,7 +3145,7 @@ void tst_QSqlQuery::sqlServerReturn0()
"SELECT * FROM "+tableName+" WHERE ID = 2 "
"RETURN 0"));
- QVERIFY_SQL(q, exec("{CALL "+procName+"}"));
+ QVERIFY_SQL(q, exec("{CALL " + procName + QLatin1Char('}')));
QVERIFY_SQL(q, next());
}
@@ -3162,7 +3162,7 @@ void tst_QSqlQuery::QTBUG_551()
TYPE IntType IS TABLE OF INTEGER INDEX BY BINARY_INTEGER;\n\
TYPE VCType IS TABLE OF VARCHAR2(60) INDEX BY BINARY_INTEGER;\n\
PROCEDURE P (Inp IN IntType, Outp OUT VCType);\n\
- END "+pkgname+";"));
+ END "+ pkgname + QLatin1Char(';')));
QVERIFY_SQL(q, exec("CREATE OR REPLACE PACKAGE BODY "+pkgname+" IS\n\
PROCEDURE P (Inp IN IntType, Outp OUT VCType)\n\
@@ -3172,7 +3172,7 @@ void tst_QSqlQuery::QTBUG_551()
Outp(2) := '2. Value is ' ||TO_CHAR(Inp(2));\n\
Outp(3) := '3. Value is ' ||TO_CHAR(Inp(3));\n\
END p;\n\
- END "+pkgname+";"));
+ END " + pkgname + QLatin1Char(';')));
QVariantList inLst, outLst, res_outLst;
@@ -3310,7 +3310,7 @@ void tst_QSqlQuery::QTBUG_6421()
QVERIFY_SQL(q, exec("create index INDEX2 on "+tableName+" (COL2 desc)"));
QVERIFY_SQL(q, exec("create index INDEX3 on "+tableName+" (COL3 desc)"));
q.setForwardOnly(true);
- QVERIFY_SQL(q, exec("select COLUMN_EXPRESSION from ALL_IND_EXPRESSIONS where TABLE_NAME='"+tableName+"'"));
+ QVERIFY_SQL(q, exec("select COLUMN_EXPRESSION from ALL_IND_EXPRESSIONS where TABLE_NAME='" + tableName + QLatin1Char('\'')));
QVERIFY_SQL(q, next());
QCOMPARE(q.value(0).toString(), QLatin1String("\"COL1\""));
QVERIFY_SQL(q, next());
@@ -3338,7 +3338,7 @@ void tst_QSqlQuery::QTBUG_6618()
"begin\n"
" raiserror('" + errorString + "', 16, 1)\n"
"end\n" ));
- q.exec("{call " + qTableName("tst_raiseError", __FILE__, db) + "}");
+ q.exec("{call " + qTableName("tst_raiseError", __FILE__, db) + QLatin1Char('}'));
QVERIFY(q.lastError().text().contains(errorString));
}
@@ -3430,7 +3430,7 @@ void tst_QSqlQuery::QTBUG_21884()
QStringList stList;
QString tableName(qTableName("bug21884", __FILE__, db));
stList << "create table " + tableName + "(id integer primary key, note string)";
- stList << "select * from " + tableName + ";";
+ stList << "select * from " + tableName + QLatin1Char(';');
stList << "select * from " + tableName + "; \t\n\r";
stList << "drop table " + tableName;
@@ -3984,7 +3984,7 @@ void runIntegralTypesMysqlTest(QSqlDatabase &db, const QString &tableName, const
{
QSqlQuery q(db);
QVERIFY_SQL(q, exec("DROP TABLE IF EXISTS " + tableName));
- QVERIFY_SQL(q, exec("CREATE TABLE " + tableName + " (id " + type + ")"));
+ QVERIFY_SQL(q, exec("CREATE TABLE " + tableName + " (id " + type + ')'));
const int steps = 20;
const T increment = max / steps - min / steps;
@@ -4001,7 +4001,7 @@ void runIntegralTypesMysqlTest(QSqlDatabase &db, const QString &tableName, const
q.bindValue(0, v);
QVERIFY_SQL(q, exec());
} else {
- QVERIFY_SQL(q, exec("INSERT INTO " + tableName + " (id) VALUES (" + QString::number(v) + ")"));
+ QVERIFY_SQL(q, exec("INSERT INTO " + tableName + " (id) VALUES (" + QString::number(v) + QLatin1Char(')')));
}
values[i] = v;
v += increment;
diff --git a/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp b/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
index 3702631275..fbc583f341 100644
--- a/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
+++ b/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
@@ -1115,7 +1115,7 @@ void tst_QSqlRelationalTableModel::casing()
QCOMPARE( rec.count(), 0);
//try an owner that does exist
- rec = db.driver()->record(db.userName() + "." + qTableName("CASETEST1", db).toUpper());
+ rec = db.driver()->record(db.userName() + QLatin1Char('.') + qTableName("CASETEST1", db).toUpper());
QCOMPARE( rec.count(), 4);
}
QSqlRecord rec = db.driver()->record(qTableName("CASETEST1", db).toUpper());
@@ -1464,13 +1464,13 @@ void tst_QSqlRelationalTableModel::psqlSchemaTest()
QSqlQuery q(db);
QVERIFY_SQL(q, exec("create schema " + qTableName("QTBUG_5373", __FILE__, db)));
QVERIFY_SQL(q, exec("create schema " + qTableName("QTBUG_5373_s2", __FILE__, db)));
- QVERIFY_SQL(q, exec("create table " + qTableName("QTBUG_5373", __FILE__, db) + "." + qTableName("document", __FILE__, db) +
+ QVERIFY_SQL(q, exec("create table " + qTableName("QTBUG_5373", __FILE__, db) + QLatin1Char('.') + qTableName("document", __FILE__, db) +
"(document_id int primary key, relatingid int, userid int)"));
- QVERIFY_SQL(q, exec("create table " + qTableName("QTBUG_5373_s2", __FILE__, db) + "." + qTableName("user", __FILE__, db) +
+ QVERIFY_SQL(q, exec("create table " + qTableName("QTBUG_5373_s2", __FILE__, db) + QLatin1Char('.') + qTableName("user", __FILE__, db) +
"(userid int primary key, username char(40))"));
- model.setTable(qTableName("QTBUG_5373", __FILE__, db) + "." + qTableName("document", __FILE__, db));
- model.setRelation(1, QSqlRelation(qTableName("QTBUG_5373_s2", __FILE__, db) + "." + qTableName("user", __FILE__, db), "userid", "username"));
- model.setRelation(2, QSqlRelation(qTableName("QTBUG_5373_s2", __FILE__, db) + "." + qTableName("user", __FILE__, db), "userid", "username"));
+ model.setTable(qTableName("QTBUG_5373", __FILE__, db) + QLatin1Char('.') + qTableName("document", __FILE__, db));
+ model.setRelation(1, QSqlRelation(qTableName("QTBUG_5373_s2", __FILE__, db) + QLatin1Char('.') + qTableName("user", __FILE__, db), "userid", "username"));
+ model.setRelation(2, QSqlRelation(qTableName("QTBUG_5373_s2", __FILE__, db) + QLatin1Char('.') + qTableName("user", __FILE__, db), "userid", "username"));
QVERIFY_SQL(model, select());
model.setJoinMode(QSqlRelationalTableModel::LeftJoin);
@@ -1515,14 +1515,14 @@ void tst_QSqlRelationalTableModel::relationOnFirstColumn()
//prepare test1 table
QSqlQuery q(db);
QVERIFY_SQL(q, exec("CREATE TABLE " + testTable1 + " (val1 INTEGER, id1 INTEGER PRIMARY KEY);"));
- QVERIFY_SQL(q, exec("DELETE FROM " + testTable1 + ";"));
+ QVERIFY_SQL(q, exec("DELETE FROM " + testTable1 + QLatin1Char(';')));
QVERIFY_SQL(q, exec("INSERT INTO " + testTable1 + " (id1, val1) VALUES(1, 10);"));
QVERIFY_SQL(q, exec("INSERT INTO " + testTable1 + " (id1, val1) VALUES(2, 20);"));
QVERIFY_SQL(q, exec("INSERT INTO " + testTable1 + " (id1, val1) VALUES(3, 30);"));
//prepare test2 table
QVERIFY_SQL(q, exec("CREATE TABLE " + testTable2 + " (id INTEGER PRIMARY KEY, name TEXT);"));
- QVERIFY_SQL(q, exec("DELETE FROM " + testTable2 + ";"));
+ QVERIFY_SQL(q, exec("DELETE FROM " + testTable2 + QLatin1Char(';')));
QVERIFY_SQL(q, exec("INSERT INTO " + testTable2 + " (id, name) VALUES (10, 'Hervanta');"));
QVERIFY_SQL(q, exec("INSERT INTO " + testTable2 + " (id, name) VALUES (20, 'Keskusta');"));
QVERIFY_SQL(q, exec("INSERT INTO " + testTable2 + " (id, name) VALUES (30, 'Annala');"));
diff --git a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp
index 2ace79973b..fff9811e60 100644
--- a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp
+++ b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp
@@ -1987,7 +1987,7 @@ void tst_QSqlTableModel::tableModifyWithBlank()
//set a filter on the table so the only record we get is the one we just made
//I could just do another setData command, but I want to make sure the TableModel
//matches exactly what is stored in the database
- model.setFilter("column1='"+timeString+"'"); //filter to get just the newly entered row
+ model.setFilter("column1='" + timeString + QLatin1Char('\'')); //filter to get just the newly entered row
QVERIFY_SQL(model, select());
//Make sure we only get one record, and that it is the one we just made