File indexing completed on 2024-04-14 14:28:44

0001 /*
0002     This file is part of the KDE project
0003     SPDX-FileCopyrightText: 2004 Arend van Beelen jr. <arend@auton.nl>
0004     SPDX-FileCopyrightText: 2010 David Faure <faure@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-only
0007 */
0008 
0009 #ifndef KFINDTEST_H
0010 #define KFINDTEST_H
0011 
0012 #include <QObject>
0013 #include <QStringList>
0014 #include <ktextwidgets_export.h>
0015 #include <memory>
0016 class KFind;
0017 class KFindRecorder : public QObject
0018 {
0019     Q_OBJECT
0020 
0021 public:
0022     explicit KFindRecorder(const QStringList &text);
0023 
0024     ~KFindRecorder() override;
0025     void find(const QString &pattern, long options = 0);
0026     bool findNext(const QString &pattern = QString());
0027 
0028     void changeText(int line, const QString &text);
0029 
0030     const QStringList &hits() const
0031     {
0032         return m_hits;
0033     }
0034     void clearHits()
0035     {
0036         m_hits.clear();
0037     }
0038 
0039 public Q_SLOTS:
0040     void slotHighlight(const QString &text, int index, int matchedLength);
0041     void slotHighlight(int id, int index, int matchedLengthlength);
0042 
0043 private:
0044     std::unique_ptr<KFind> m_find;
0045     QStringList m_text;
0046     int m_line;
0047     QStringList m_hits;
0048 };
0049 
0050 class TestKFind : public QObject
0051 {
0052     Q_OBJECT
0053 
0054 public:
0055     TestKFind();
0056 
0057 private Q_SLOTS:
0058 
0059 #if KTEXTWIDGETS_BUILD_DEPRECATED_SINCE(5, 70)
0060     void testStaticFindString_data();
0061     void testStaticFindString();
0062 #endif
0063     void testStaticFindRegexp_data();
0064     void testStaticFindRegexp();
0065 
0066     void testRegexpUnicode_data();
0067     void testRegexpUnicode();
0068 
0069     void testSimpleSearch();
0070     void testSimpleRegexp();
0071 
0072 #if KTEXTWIDGETS_BUILD_DEPRECATED_SINCE(5, 70)
0073     void testLineBeginRegexp();
0074 #endif
0075 
0076     void testLineBeginRegularExpression();
0077     void testFindIncremental();
0078     void testFindIncrementalDynamic();
0079 
0080 private:
0081     QString m_text;
0082 };
0083 
0084 #endif