From 6be26d90517bcbae252689679371cd4c7b7bbe3e Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Tue, 2 Sep 2014 09:13:10 +0200 Subject: 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 --- .../tools/qregularexpression/tst_qregularexpression.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests/auto/corelib/tools/qregularexpression') 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 ®exp, 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(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; -- cgit v1.2.3