diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-04-02 11:00:06 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-04-03 21:01:53 +0200 |
commit | cc6c5ae70b1389ed86301bbfc156628e1d3abbcd (patch) | |
tree | 41238618977b44c67c796fb34078d6c3084d5e55 /tests/auto/quick/scenegraph/tst_scenegraph.cpp | |
parent | 55be24d6b6e66bd54168021f5a467ba4da73b2c6 (diff) |
Port the remaining tests from QRegExp to QRegularExpression
Change-Id: If258701759c5da206948407feccd94e323af6b36
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/quick/scenegraph/tst_scenegraph.cpp')
-rw-r--r-- | tests/auto/quick/scenegraph/tst_scenegraph.cpp | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/tests/auto/quick/scenegraph/tst_scenegraph.cpp b/tests/auto/quick/scenegraph/tst_scenegraph.cpp index 12f7efb7d5..c026888f6c 100644 --- a/tests/auto/quick/scenegraph/tst_scenegraph.cpp +++ b/tests/auto/quick/scenegraph/tst_scenegraph.cpp @@ -342,13 +342,13 @@ struct Sample { qreal tolerance; }; -static Sample sample_from_regexp(QRegExp *re) { - return Sample(re->cap(1).toInt(), - re->cap(2).toInt(), - re->cap(3).toFloat(), - re->cap(4).toFloat(), - re->cap(5).toFloat(), - re->cap(6).toFloat() +static Sample sample_from_regexp(QRegularExpressionMatch *match) { + return Sample(match->captured(1).toInt(), + match->captured(2).toInt(), + match->captured(3).toFloat(), + match->captured(4).toFloat(), + match->captured(5).toFloat(), + match->captured(6).toFloat() ); } @@ -406,10 +406,10 @@ void tst_SceneGraph::render_data() if (!m_brokenMipmapSupport) files << "render_Mipmap.qml"; - QRegExp sampleCount("#samples: *(\\d+)"); + QRegularExpression sampleCount("#samples: *(\\d+)"); // X:int Y:int R:float G:float B:float Error:float - QRegExp baseSamples("#base: *(\\d+) *(\\d+) *(\\d\\.\\d+) *(\\d\\.\\d+) *(\\d\\.\\d+) *(\\d\\.\\d+)"); - QRegExp finalSamples("#final: *(\\d+) *(\\d+) *(\\d\\.\\d+) *(\\d\\.\\d+) *(\\d\\.\\d+) *(\\d\\.\\d+)"); + QRegularExpression baseSamples("#base: *(\\d+) *(\\d+) *(\\d\\.\\d+) *(\\d\\.\\d+) *(\\d\\.\\d+) *(\\d\\.\\d+)"); + QRegularExpression finalSamples("#final: *(\\d+) *(\\d+) *(\\d\\.\\d+) *(\\d\\.\\d+) *(\\d\\.\\d+) *(\\d\\.\\d+)"); foreach (QString fileName, files) { QFile file(testFile(fileName)); @@ -421,8 +421,9 @@ void tst_SceneGraph::render_data() int samples = -1; foreach (QString line, contents) { - if (sampleCount.indexIn(line) >= 0) { - samples = sampleCount.cap(1).toInt(); + auto match = sampleCount.match(line); + if (match.hasMatch()) { + samples = match.captured(1).toInt(); break; } } @@ -431,10 +432,11 @@ void tst_SceneGraph::render_data() QList<Sample> baseStage, finalStage; foreach (QString line, contents) { - if (baseSamples.indexIn(line) >= 0) - baseStage << sample_from_regexp(&baseSamples); - else if (finalSamples.indexIn(line) >= 0) - finalStage << sample_from_regexp(&finalSamples); + auto match = baseSamples.match(line); + if (match.hasMatch()) + baseStage << sample_from_regexp(&match); + else if ((match = finalSamples.match(line)).hasMatch()) + finalStage << sample_from_regexp(&match); } if (baseStage.size() + finalStage.size() != samples) |