summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp')
-rw-r--r--tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
index 6a2ae4951b..5f5cd78215 100644
--- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
+++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
@@ -199,6 +199,12 @@ private slots:
void findWithRegExpReturnsFalseIfNoMoreResults();
#endif
+#if QT_CONFIG(regularexpression)
+ void findWithRegularExpression();
+ void findBackwardWithRegularExpression();
+ void findWithRegularExpressionReturnsFalseIfNoMoreResults();
+#endif
+
#if QT_CONFIG(wheelevent)
void wheelEvent();
#endif
@@ -2572,6 +2578,45 @@ void tst_QTextEdit::findWithRegExpReturnsFalseIfNoMoreResults()
}
#endif
+#if QT_CONFIG(regularexpression)
+void tst_QTextEdit::findWithRegularExpression()
+{
+ ed->setHtml(QStringLiteral("arbitrary te<span style=\"color:#ff0000\">xt</span>"));
+ QRegularExpression rx("\\w{2}xt");
+
+ bool found = ed->find(rx);
+
+ QVERIFY(found);
+ QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("text"));
+}
+
+void tst_QTextEdit::findBackwardWithRegularExpression()
+{
+ ed->setPlainText(QStringLiteral("arbitrary text"));
+ QTextCursor cursor = ed->textCursor();
+ cursor.movePosition(QTextCursor::End);
+ ed->setTextCursor(cursor);
+ QRegularExpression rx("a\\w*t");
+
+ bool found = ed->find(rx, QTextDocument::FindBackward);
+
+ QVERIFY(found);
+ QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("arbit"));
+}
+
+void tst_QTextEdit::findWithRegularExpressionReturnsFalseIfNoMoreResults()
+{
+ ed->setPlainText(QStringLiteral("arbitrary text"));
+ QRegularExpression rx("t.xt");
+ ed->find(rx);
+
+ bool found = ed->find(rx);
+
+ QVERIFY(!found);
+ QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("text"));
+}
+#endif
+
#if QT_CONFIG(wheelevent)
class TextEdit : public QTextEdit