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>
bb10
Giuseppe D'Angelo 2014-09-02 09:13:10 +02:00
parent de4cad945d
commit 6be26d9051
1 changed files with 13 additions and 0 deletions

View File

@ -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;