summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qregularexpression
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2014-09-02 09:13:10 +0200
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2014-09-12 08:33:12 +0200
commit6be26d90517bcbae252689679371cd4c7b7bbe3e (patch)
treecc7a78462255c3e5c23e90e0e177a6d6460ca296 /tests/auto/corelib/tools/qregularexpression
parentde4cad945dcacd7bfba17a8dd7bf482ab14ab59a (diff)
QRegularExpression: more QStringRef tests
So far we've only tested matching against QStringRefs which were spanning the entire underlying QString. Instead, use the offset matching to also perform tests using "proper" substrings. Change-Id: Ia66e23f738b52997311ed2cf869e595079984292 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'tests/auto/corelib/tools/qregularexpression')
-rw-r--r--tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp
index 520e668ce2..18104a05e6 100644
--- a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp
+++ b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp
@@ -314,6 +314,19 @@ static void testMatch(const QRegularExpression &regexp,
matchType,
matchOptions,
result);
+
+ // offset <= 0 tested above; now also test stringrefs not spanning over
+ // the entire subject. Note that the offset can be negative, hence the above
+ // tests can't be merged into this one
+ for (int i = 1; i <= offset; ++i) {
+ testMatchImpl<QREMatch>(regexp,
+ matchingMethodForStringRef,
+ QStringRef(&subject, i, subject.length() - i),
+ offset - i,
+ matchType,
+ matchOptions,
+ result);
+ }
}
typedef QRegularExpressionMatch (QRegularExpression::*QREMatchStringPMF)(const QString &, int, QRegularExpression::MatchType, QRegularExpression::MatchOptions) const;