summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorSamuel Gaist <samuel.gaist@idiap.ch>2018-08-01 00:07:11 +0200
committerSamuel Gaist <samuel.gaist@idiap.ch>2018-08-16 16:30:14 +0000
commit30b0701c9b50ec718ec858d7777a01c66e333a9c (patch)
tree21f5eb38257aaa50ab18b4ae9d1e644170f8efbe /tests/auto
parent0f6b941ca54f9714627b8d5a94be163dc02126c1 (diff)
Refactor wildcard support in QRegularExpression
The API originally proposed was flawed in the sense that the setter function would use a modified version of the parameter given which would have make it a black box for the user. This patch fixes that by removing that setter and providing a static method that will return the pattern suitably modified to be used by QRegularExpression the same way the escape method does. [ChangeLog][Core][QRegularExpression] Implemented support for wildcard patterns through a static method. Change-Id: I0054bcaffd7525dac569f54fa81f73b7e4544b2e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp
index 5130b7cfcd..987ca519ee 100644
--- a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp
+++ b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp
@@ -2171,6 +2171,10 @@ void tst_QRegularExpression::wildcard_data()
addRow(".???l", "test.html", 4);
addRow("?", "test.html", 0);
addRow("?m", "test.html", 6);
+ addRow("[*]", "test.html", -1);
+ addRow("[?]","test.html", -1);
+ addRow("[[]","test.h[ml", 6);
+ addRow("[]]","test.h]ml", 6);
addRow(".h[a-z]ml", "test.html", 4);
addRow(".h[A-Z]ml", "test.html", -1);
addRow(".h[A-Z]ml", "test.hTml", 4);
@@ -2191,9 +2195,7 @@ void tst_QRegularExpression::wildcard()
QFETCH(QString, string);
QFETCH(int, foundIndex);
- QRegularExpression re;
- re.setWildcardPattern(pattern);
-
+ QRegularExpression re(QRegularExpression::wildcardToRegularExpression(pattern));
QRegularExpressionMatch match = re.match(string);
QCOMPARE(match.capturedStart(), foundIndex);
@@ -2217,11 +2219,9 @@ void tst_QRegularExpression::testInvalidWildcard_data()
void tst_QRegularExpression::testInvalidWildcard()
{
QFETCH(QString, pattern);
-
- QRegularExpression re;
- re.setWildcardPattern(pattern);
-
QFETCH(bool, isValid);
+
+ QRegularExpression re(QRegularExpression::wildcardToRegularExpression(pattern));
QCOMPARE(re.isValid(), isValid);
}