summaryrefslogtreecommitdiff
path: root/tests/auto/sql/models/qsqlquerymodel
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2023-03-17 22:45:18 +0100
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2023-04-07 20:38:13 +0200
commit40045aeec88afdd2f62629042352b0d17fadcf0b (patch)
tree728ca4de7dfb3f9c18ee4ad817cc78b5c91937de /tests/auto/sql/models/qsqlquerymodel
parentb40df32ea324a0b26816902df4b9dbeb23a21030 (diff)
downloadqtbase-40045aeec88afdd2f62629042352b0d17fadcf0b.tar.gz
SQL/Tests: use TableScope where possible
Use TableScope helper class to make sure the table used for the test is really cleaned up before usage. Change-Id: I45fffcd13acae6032636ae07097b14af174ede21 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/auto/sql/models/qsqlquerymodel')
-rw-r--r--tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp b/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp
index 202fc1080c..a6915243a6 100644
--- a/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp
+++ b/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp
@@ -62,9 +62,9 @@ private slots:
void task_QTBUG_4963_setHeaderDataWithProxyModel();
private:
- void generic_data(const QString &engine=QString());
- void dropTestTables(QSqlDatabase db);
- void createTestTables(QSqlDatabase db);
+ void generic_data(const QString &engine = QString());
+ void dropTestTables(const QSqlDatabase &db);
+ void createTestTables(const QSqlDatabase &db);
void populateTestTables(QSqlDatabase db);
tst_Databases dbs;
};
@@ -73,8 +73,8 @@ private:
class DBTestModel: public QSqlQueryModel
{
public:
- DBTestModel(QObject *parent = nullptr): QSqlQueryModel(parent) {}
- QModelIndex indexInQuery(const QModelIndex &item) const override { return QSqlQueryModel::indexInQuery(item); }
+ using QSqlQueryModel::QSqlQueryModel;
+ using QSqlQueryModel::indexInQuery;
};
tst_QSqlQueryModel::tst_QSqlQueryModel()
@@ -88,8 +88,8 @@ tst_QSqlQueryModel::~tst_QSqlQueryModel()
void tst_QSqlQueryModel::initTestCase()
{
QVERIFY(dbs.open());
- for (QStringList::ConstIterator it = dbs.dbNames.begin(); it != dbs.dbNames.end(); ++it) {
- QSqlDatabase db = QSqlDatabase::database((*it));
+ for (const auto &dbName : std::as_const(dbs.dbNames)) {
+ QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
dropTestTables(db); //in case of leftovers
createTestTables(db);
@@ -99,15 +99,15 @@ void tst_QSqlQueryModel::initTestCase()
void tst_QSqlQueryModel::cleanupTestCase()
{
- for (QStringList::ConstIterator it = dbs.dbNames.begin(); it != dbs.dbNames.end(); ++it) {
- QSqlDatabase db = QSqlDatabase::database((*it));
+ for (const auto &dbName : std::as_const(dbs.dbNames)) {
+ QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
dropTestTables(db);
}
dbs.close();
}
-void tst_QSqlQueryModel::dropTestTables(QSqlDatabase db)
+void tst_QSqlQueryModel::dropTestTables(const QSqlDatabase &db)
{
QStringList tableNames;
tableNames << qTableName("test", __FILE__, db)
@@ -117,7 +117,7 @@ void tst_QSqlQueryModel::dropTestTables(QSqlDatabase db)
tst_Databases::safeDropTables(db, tableNames);
}
-void tst_QSqlQueryModel::createTestTables(QSqlDatabase db)
+void tst_QSqlQueryModel::createTestTables(const QSqlDatabase &db)
{
dropTestTables(db);
QSqlQuery q(db);