diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2018-12-04 01:18:46 +0100 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2020-09-30 21:39:36 +0200 |
commit | 7ee682a1ddc259225618b57ff00f4c36ff5e724c (patch) | |
tree | a77abbd03cd81c6daaaa4a020065a1582a8604f9 /tests/auto/corelib/text/qregularexpression/tst_qregularexpression.cpp | |
parent | cc692bb58c8a39f06eb30c04cfcb61fa466d18ae (diff) |
QREMatchIterator: add support for range-based for
Add begin()/end() on QRegularExpressionMatchIterator, making
iterators over an iterator (like directory_iterator).
[ChangeLog][QtCore][QRegularExpression] The iterator object
(QRegularExpressionMatchIterator) returned by a global match
is now usable in a range-based for loop.
Change-Id: If3d31bd2e84e7d1fb626a0b3d2745914dff03e39
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/text/qregularexpression/tst_qregularexpression.cpp')
-rw-r--r-- | tests/auto/corelib/text/qregularexpression/tst_qregularexpression.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/corelib/text/qregularexpression/tst_qregularexpression.cpp b/tests/auto/corelib/text/qregularexpression/tst_qregularexpression.cpp index a986223a87..dd96b158f4 100644 --- a/tests/auto/corelib/text/qregularexpression/tst_qregularexpression.cpp +++ b/tests/auto/corelib/text/qregularexpression/tst_qregularexpression.cpp @@ -184,6 +184,27 @@ bool operator==(const QRegularExpressionMatchIterator &iterator, const QList<Mat if (i.hasNext()) return false; + i = iterator; + + int index = 0; + for (const QRegularExpressionMatch &match : i) { + if (match != expectedMatchList[index++]) + return false; + } + + if (index != expectedMatchList.size()) + return false; + + // do it again + index = 0; + for (const QRegularExpressionMatch &match : i) { + if (match != expectedMatchList[index++]) + return false; + } + + if (index != expectedMatchList.size()) + return false; + return true; } |