summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2012-03-12 21:03:49 +0100
committerLars Knoll <lars.knoll@nokia.com>2012-03-12 21:03:49 +0100
commitd5098f2802255da10b749b93705084ad1fdfc6a5 (patch)
tree6462008a4ab7d13435d93490fed96c62c516cbdf /tests/auto/corelib/tools
parentd5a85940f785459d7b982d5fdf59a9fd18825092 (diff)
parentb5b41c18345719612e5411cc482466d2dbafdaf7 (diff)
Merge remote-tracking branch 'origin/master' into api_changes
Conflicts: tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp Change-Id: I884afc3b6d65c6411733a897a1949e19393573a7
Diffstat (limited to 'tests/auto/corelib/tools')
-rw-r--r--tests/auto/corelib/tools/qlist/tst_qlist.cpp6
-rw-r--r--tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp85
-rw-r--r--tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.h4
3 files changed, 88 insertions, 7 deletions
diff --git a/tests/auto/corelib/tools/qlist/tst_qlist.cpp b/tests/auto/corelib/tools/qlist/tst_qlist.cpp
index 3baa47f013..c883c1c5f6 100644
--- a/tests/auto/corelib/tools/qlist/tst_qlist.cpp
+++ b/tests/auto/corelib/tools/qlist/tst_qlist.cpp
@@ -43,12 +43,6 @@
#include <QtTest/QtTest>
#include <QList>
-/*!
- \class tst_QVector
- \internal
- \since 4.5
- \brief Test Qt's class QList.
- */
class tst_QList : public QObject
{
Q_OBJECT
diff --git a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp
index 72157c0536..a4c04d6207 100644
--- a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp
+++ b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp
@@ -95,8 +95,13 @@ bool operator==(const QRegularExpressionMatch &rem, const Match &m)
}
Q_FOREACH (const QString &name, m.namedCaptured.keys()) {
- if (rem.captured(name) != m.namedCaptured.value(name))
+ QString remCaptured = rem.captured(name);
+ QString mCaptured = m.namedCaptured.value(name);
+ if (remCaptured != mCaptured
+ || remCaptured.isNull() != mCaptured.isNull()
+ || remCaptured.isEmpty() != mCaptured.isEmpty()) {
return false;
+ }
}
}
@@ -571,6 +576,32 @@ void tst_QRegularExpression::normalMatch_data()
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
+ // non existing names for capturing groups
+ m.clear();
+ m.isValid = true; m.hasMatch = true;
+ m.captured << "a string" << "a" << "string";
+ m.namedCaptured["article"] = "a";
+ m.namedCaptured["noun"] = "string";
+ m.namedCaptured["nonexisting1"] = QString();
+ m.namedCaptured["nonexisting2"] = QString();
+ m.namedCaptured["nonexisting3"] = QString();
+ QTest::newRow("match10") << QRegularExpression("(?<article>\\w+) (?<noun>\\w+)")
+ << "a string"
+ << 0
+ << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
+ << m;
+
+ m.clear();
+ m.isValid = true; m.hasMatch = true;
+ m.captured << "" << "";
+ m.namedCaptured["digits"] = ""; // empty VS null
+ m.namedCaptured["nonexisting"] = QString();
+ QTest::newRow("match11") << QRegularExpression("(?<digits>\\d*)")
+ << "abcde"
+ << 0
+ << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
+ << m;
+
// ***
m.clear();
@@ -1196,3 +1227,55 @@ void tst_QRegularExpression::captureCount()
if (!re.isValid())
QCOMPARE(re.captureCount(), -1);
}
+
+void tst_QRegularExpression::pcreJitStackUsage_data()
+{
+ QTest::addColumn<QString>("pattern");
+ QTest::addColumn<QString>("subject");
+ // these patterns cause enough backtrack (or even infinite recursion)
+ // in the regexp engine, so that JIT requests more memory.
+ QTest::newRow("jitstack01") << "(?(R)a*(?1)|((?R))b)" << "aaaabcde";
+ QTest::newRow("jitstack02") << "(?(R)a*(?1)|((?R))b)" << "aaaaaaabcde";
+}
+
+void tst_QRegularExpression::pcreJitStackUsage()
+{
+ QFETCH(QString, pattern);
+ QFETCH(QString, subject);
+
+ QRegularExpression re(pattern);
+ QVERIFY(re.isValid());
+ QRegularExpressionMatch match = re.match(subject);
+ consistencyCheck(match);
+ QRegularExpressionMatchIterator iterator = re.globalMatch(subject);
+ consistencyCheck(iterator);
+ while (iterator.hasNext()) {
+ match = iterator.next();
+ consistencyCheck(match);
+ }
+}
+
+void tst_QRegularExpression::regularExpressionMatch_data()
+{
+ QTest::addColumn<QString>("pattern");
+ QTest::addColumn<QString>("subject");
+
+ QTest::newRow("validity01") << "(?<digits>\\d+)" << "1234 abcd";
+ QTest::newRow("validity02") << "(?<digits>\\d+) (?<alpha>\\w+)" << "1234 abcd";
+}
+
+void tst_QRegularExpression::regularExpressionMatch()
+{
+ QFETCH(QString, pattern);
+ QFETCH(QString, subject);
+
+ QRegularExpression re(pattern);
+ QVERIFY(re.isValid());
+ QRegularExpressionMatch match = re.match(subject);
+ consistencyCheck(match);
+ QCOMPARE(match.captured("non-existing").isNull(), true);
+ QTest::ignoreMessage(QtWarningMsg, "QRegularExpressionMatch::captured: empty capturing group name passed");
+ QCOMPARE(match.captured("").isNull(), true);
+ QTest::ignoreMessage(QtWarningMsg, "QRegularExpressionMatch::captured: empty capturing group name passed");
+ QCOMPARE(match.captured(QString()).isNull(), true);
+}
diff --git a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.h b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.h
index 1a703a8f92..72a19199fd 100644
--- a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.h
+++ b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.h
@@ -71,6 +71,10 @@ private slots:
void operatoreq();
void captureCount_data();
void captureCount();
+ void pcreJitStackUsage_data();
+ void pcreJitStackUsage();
+ void regularExpressionMatch_data();
+ void regularExpressionMatch();
private:
void provideRegularExpressions();