mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2025-07-07 01:35:25 +08:00
qt 6.6.0 clean
This commit is contained in:
@ -2446,54 +2446,79 @@ void tst_QRegularExpression::wildcard_data()
|
||||
{
|
||||
QTest::addColumn<QString>("pattern");
|
||||
QTest::addColumn<QString>("string");
|
||||
QTest::addColumn<qsizetype>("foundIndex");
|
||||
QTest::addColumn<bool>("matchesPathGlob");
|
||||
QTest::addColumn<bool>("matchesNonPathGlob");
|
||||
QTest::addColumn<bool>("anchored");
|
||||
|
||||
auto addRow = [](const char *pattern, const char *string, qsizetype foundIndex) {
|
||||
QTest::addRow("%s@%s", pattern, string) << pattern << string << foundIndex;
|
||||
auto addRow = [](const char *pattern, const char *string, bool matchesPathGlob, bool matchesNonPathGlob, bool anchored = true) {
|
||||
QTest::addRow("%s@%s", pattern, string) << pattern << string << matchesPathGlob << matchesNonPathGlob << anchored;
|
||||
};
|
||||
|
||||
addRow("*.html", "test.html", 0);
|
||||
addRow("*.html", "test.htm", -1);
|
||||
addRow("*bar*", "foobarbaz", 0);
|
||||
addRow("*", "Qt Rocks!", 0);
|
||||
addRow("*.h", "test.cpp", -1);
|
||||
addRow("*.???l", "test.html", 0);
|
||||
addRow("*?", "test.html", 0);
|
||||
addRow("*?ml", "test.html", 0);
|
||||
addRow("*[*]", "test.html", -1);
|
||||
addRow("*[?]","test.html", -1);
|
||||
addRow("*[?]ml","test.h?ml", 0);
|
||||
addRow("*[[]ml","test.h[ml", 0);
|
||||
addRow("*[]]ml","test.h]ml", 0);
|
||||
addRow("*.h[a-z]ml", "test.html", 0);
|
||||
addRow("*.h[A-Z]ml", "test.html", -1);
|
||||
addRow("*.h[A-Z]ml", "test.hTml", 0);
|
||||
addRow("*.h[!A-Z]ml", "test.hTml", -1);
|
||||
addRow("*.h[!A-Z]ml", "test.html", 0);
|
||||
addRow("*.h[!T]ml", "test.hTml", -1);
|
||||
addRow("*.h[!T]ml", "test.html", 0);
|
||||
addRow("*.h[!T]m[!L]", "test.htmL", -1);
|
||||
addRow("*.h[!T]m[!L]", "test.html", 0);
|
||||
addRow("*.h[][!]ml", "test.h]ml", 0);
|
||||
addRow("*.h[][!]ml", "test.h[ml", 0);
|
||||
addRow("*.h[][!]ml", "test.h!ml", 0);
|
||||
addRow("*.html", "test.html", true, true);
|
||||
addRow("*.html", "test.htm", false, false);
|
||||
addRow("*bar*", "foobarbaz", true, true);
|
||||
addRow("*", "Qt Rocks!", true, true);
|
||||
addRow("*.h", "test.cpp", false, false);
|
||||
addRow("*.???l", "test.html", true, true);
|
||||
addRow("*?", "test.html", true, true);
|
||||
addRow("*?ml", "test.html", true, true);
|
||||
addRow("*[*]", "test.html", false, false);
|
||||
addRow("*[?]","test.html", false, false);
|
||||
addRow("*[?]ml","test.h?ml", true, true);
|
||||
addRow("*[[]ml","test.h[ml", true, true);
|
||||
addRow("*[]]ml","test.h]ml", true, true);
|
||||
addRow("*.h[a-z]ml", "test.html", true, true);
|
||||
addRow("*.h[A-Z]ml", "test.html", false, false);
|
||||
addRow("*.h[A-Z]ml", "test.hTml", true, true);
|
||||
addRow("*.h[!A-Z]ml", "test.hTml", false, false);
|
||||
addRow("*.h[!A-Z]ml", "test.html", true, true);
|
||||
addRow("*.h[!T]ml", "test.hTml", false, false);
|
||||
addRow("*.h[!T]ml", "test.html", true, true);
|
||||
addRow("*.h[!T]m[!L]", "test.htmL", false, false);
|
||||
addRow("*.h[!T]m[!L]", "test.html", true, true);
|
||||
addRow("*.h[][!]ml", "test.h]ml", true, true);
|
||||
addRow("*.h[][!]ml", "test.h[ml", true, true);
|
||||
addRow("*.h[][!]ml", "test.h!ml", true, true);
|
||||
|
||||
addRow("foo/*/bar", "foo/baz/bar", 0);
|
||||
addRow("foo/(*)/bar", "foo/baz/bar", -1);
|
||||
addRow("foo/(*)/bar", "foo/(baz)/bar", 0);
|
||||
addRow("foo/?/bar", "foo/Q/bar", 0);
|
||||
addRow("foo/?/bar", "foo/Qt/bar", -1);
|
||||
addRow("foo/(?)/bar", "foo/Q/bar", -1);
|
||||
addRow("foo/(?)/bar", "foo/(Q)/bar", 0);
|
||||
addRow("foo/*/bar", "foo/baz/bar", true, true);
|
||||
addRow("foo/*/bar", "foo/fie/baz/bar", false, true);
|
||||
addRow("foo?bar", "foo/bar", false, true);
|
||||
addRow("foo/(*)/bar", "foo/baz/bar", false, false);
|
||||
addRow("foo/(*)/bar", "foo/(baz)/bar", true, true);
|
||||
addRow("foo/?/bar", "foo/Q/bar", true, true);
|
||||
addRow("foo/?/bar", "foo/Qt/bar", false, false);
|
||||
addRow("foo/(?)/bar", "foo/Q/bar", false, false);
|
||||
addRow("foo/(?)/bar", "foo/(Q)/bar", true, true);
|
||||
|
||||
addRow("foo*bar", "foo/fie/baz/bar", false, true);
|
||||
addRow("foo*bar", "foo bar", true, true);
|
||||
addRow("foo*bar", "foo\tbar", true, true);
|
||||
addRow("foo*bar", "foo\nbar", true, true);
|
||||
addRow("foo*bar", "foo\r\nbar", true, true);
|
||||
|
||||
// different anchor modes
|
||||
addRow("foo", "afoob", false, false, true);
|
||||
addRow("foo", "afoob", true, true, false);
|
||||
|
||||
addRow("fie*bar", "foo/fie/baz/bar", false, false, true);
|
||||
addRow("fie*bar", "foo/fie/baz/bar", false, true, false);
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
addRow("foo\\*\\bar", "foo\\baz\\bar", 0);
|
||||
addRow("foo\\(*)\\bar", "foo\\baz\\bar", -1);
|
||||
addRow("foo\\(*)\\bar", "foo\\(baz)\\bar", 0);
|
||||
addRow("foo\\?\\bar", "foo\\Q\\bar", 0);
|
||||
addRow("foo\\?\\bar", "foo\\Qt\\bar", -1);
|
||||
addRow("foo\\(?)\\bar", "foo\\Q\\bar", -1);
|
||||
addRow("foo\\(?)\\bar", "foo\\(Q)\\bar", 0);
|
||||
addRow("foo\\*\\bar", "foo\\baz\\bar", true, true);
|
||||
addRow("foo\\*\\bar", "foo/baz/bar", true, false);
|
||||
addRow("foo\\*\\bar", "foo/baz\\bar", true, false);
|
||||
addRow("foo\\*\\bar", "foo\\fie\\baz\\bar", false, true);
|
||||
addRow("foo\\*\\bar", "foo/fie/baz/bar", false, false);
|
||||
addRow("foo/*/bar", "foo\\baz\\bar", true, false);
|
||||
addRow("foo/*/bar", "foo/baz/bar", true, true);
|
||||
addRow("foo/*/bar", "foo\\fie\\baz\\bar", false, false);
|
||||
addRow("foo/*/bar", "foo/fie/baz/bar", false, true);
|
||||
addRow("foo\\(*)\\bar", "foo\\baz\\bar", false, false);
|
||||
addRow("foo\\(*)\\bar", "foo\\(baz)\\bar", true, true);
|
||||
addRow("foo\\?\\bar", "foo\\Q\\bar", true, true);
|
||||
addRow("foo\\?\\bar", "foo\\Qt\\bar", false, false);
|
||||
addRow("foo\\(?)\\bar", "foo\\Q\\bar", false, false);
|
||||
addRow("foo\\(?)\\bar", "foo\\(Q)\\bar", true, true);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -2501,12 +2526,22 @@ void tst_QRegularExpression::wildcard()
|
||||
{
|
||||
QFETCH(QString, pattern);
|
||||
QFETCH(QString, string);
|
||||
QFETCH(qsizetype, foundIndex);
|
||||
QFETCH(bool, matchesPathGlob);
|
||||
QFETCH(bool, matchesNonPathGlob);
|
||||
QFETCH(bool, anchored);
|
||||
|
||||
QRegularExpression re(QRegularExpression::wildcardToRegularExpression(pattern));
|
||||
QRegularExpressionMatch match = re.match(string);
|
||||
QRegularExpression::WildcardConversionOptions options = {};
|
||||
if (!anchored)
|
||||
options |= QRegularExpression::UnanchoredWildcardConversion;
|
||||
|
||||
QCOMPARE(match.capturedStart(), foundIndex);
|
||||
{
|
||||
QRegularExpression re(QRegularExpression::wildcardToRegularExpression(pattern, options));
|
||||
QCOMPARE(string.contains(re), matchesPathGlob);
|
||||
}
|
||||
{
|
||||
QRegularExpression re(QRegularExpression::wildcardToRegularExpression(pattern, options | QRegularExpression::NonPathWildcardConversion));
|
||||
QCOMPARE(string.contains(re), matchesNonPathGlob);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QRegularExpression::testInvalidWildcard_data()
|
||||
|
Reference in New Issue
Block a user