diff options
author | Samuel Gaist <samuel.gaist@idiap.ch> | 2018-08-01 00:28:26 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2018-08-18 21:59:38 +0000 |
commit | 3746eb8412ea42d7e3c519926460482530782a75 (patch) | |
tree | 747d80b4487c14ea7b73bdd848ff098abae42e95 /tests/auto/corelib/tools | |
parent | cfcfc96d8f918e16b35e30cead4a4bc370bb690b (diff) |
QRegularExpression: refactor wildcard translation
This patch refactors the wildcardToRegularExpression method to generate
a simpler regular expression. It also fixes some shortcomings of the
previous implementation.
Tests have been updated to ensure all cases are properly supported.
Change-Id: I454e3fe8fe0bb663b2f319d6fa2fa8aec626c50d
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/auto/corelib/tools')
-rw-r--r-- | tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp index 987ca519ee..f520e9742a 100644 --- a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp +++ b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp @@ -2173,6 +2173,7 @@ void tst_QRegularExpression::wildcard_data() addRow("?m", "test.html", 6); addRow("[*]", "test.html", -1); addRow("[?]","test.html", -1); + addRow("[?]","test.h?ml", 6); addRow("[[]","test.h[ml", 6); addRow("[]]","test.h]ml", 6); addRow(".h[a-z]ml", "test.html", 4); @@ -2187,6 +2188,24 @@ void tst_QRegularExpression::wildcard_data() addRow(".h[][!]", "test.h]ml", 4); addRow(".h[][!]", "test.h[ml", 4); addRow(".h[][!]", "test.h!ml", 4); + + addRow("foo/*/bar", "Qt/foo/baz/bar", 3); + addRow("foo/(*)/bar", "Qt/foo/baz/bar", -1); + addRow("foo/(*)/bar", "Qt/foo/(baz)/bar", 3); + addRow("foo/?/bar", "Qt/foo/Q/bar", 3); + addRow("foo/?/bar", "Qt/foo/Qt/bar", -1); + addRow("foo/(?)/bar", "Qt/foo/Q/bar", -1); + addRow("foo/(?)/bar", "Qt/foo/(Q)/bar", 3); + +#ifdef Q_OS_WIN + addRow("foo\\*\\bar", "Qt\\foo\\baz\\bar", 3); + addRow("foo\\(*)\\bar", "Qt\\foo\\baz\\bar", -1); + addRow("foo\\(*)\\bar", "Qt\\foo\\(baz)\\bar", 3); + addRow("foo\\?\\bar", "Qt\\foo\\Q\\bar", 3); + addRow("foo\\?\\bar", "Qt\\foo\\Qt\\bar", -1); + addRow("foo\\(?)\\bar", "Qt\\foo\\Q\\bar", -1); + addRow("foo\\(?)\\bar", "Qt\\foo\\(Q)\\bar", 3); +#endif } void tst_QRegularExpression::wildcard() |