diff options
author | Samuel Gaist <samuel.gaist@idiap.ch> | 2019-01-07 17:40:26 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-01-09 10:54:20 +0000 |
commit | cffba828bc53fab284f030b8131ea47913108618 (patch) | |
tree | 62b0cf6c0466d464d382403828df7c5872347a6d /tests/manual/widgets | |
parent | da7f548954c39b17277ca504d494410937ebb458 (diff) |
Test: port tests to QRegularExpression
This patch updates the tests to use QRegularExpression in place of
QRegExp which is to be considered deprecated.
Fixes: QTBUG-72596
Change-Id: Idebd9595b60d653974aa6ac49a75e2f90fea184f
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Diffstat (limited to 'tests/manual/widgets')
-rw-r--r-- | tests/manual/widgets/inputmethods/testview.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/tests/manual/widgets/inputmethods/testview.cpp b/tests/manual/widgets/inputmethods/testview.cpp index d41734c2d..14e355caf 100644 --- a/tests/manual/widgets/inputmethods/testview.cpp +++ b/tests/manual/widgets/inputmethods/testview.cpp @@ -31,7 +31,7 @@ #include <QDebug> #include <QFile> #include <QPushButton> -#include <QRegExp> +#include <QRegularExpression> #include <QStandardItemModel> #include <QTableView> #include <QTest> @@ -77,15 +77,16 @@ void TestView::loadTestData(const QString &testDataPath) QTextStream testDataStream(&testDataFile); while (!testDataStream.atEnd()) { QString line = testDataStream.readLine(); - QRegExp data("^\"(.*)\"\\s*,\\s*(-?\\d+)\\s*,\\s*(-?\\d+)\\s*,\\s*(\\d+)\\s*,\\s*\"(.*)\"\\s*,\\s*\"(.*)\"\\s*$"); - if (!data.exactMatch(line)) + QRegularExpression data(QRegularExpression::anchoredPattern("^\"(.*)\"\\s*,\\s*(-?\\d+)\\s*,\\s*(-?\\d+)\\s*,\\s*(\\d+)\\s*,\\s*\"(.*)\"\\s*,\\s*\"(.*)\"\\s*$")); + QRegularExpressionMatch match = data.match(line); + if (!match.hasMatch()) continue; QStandardItemModel *model = qobject_cast<QStandardItemModel *>(m_tableView->model()); QList<QStandardItem *> row; - for (int i = 1; i <= data.captureCount(); ++i) - row.append(new QStandardItem(data.cap(i))); + for (int i = 1; i <= match.lastCapturedIndex(); ++i) + row.append(new QStandardItem(match.captured(i))); model->appendRow(row); } |