File: kfindtest.h

package info (click to toggle)
kf6-ktextwidgets 6.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 23,984 kB
  • sloc: cpp: 5,382; sh: 18; makefile: 7
file content (76 lines) | stat: -rw-r--r-- 1,529 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
    This file is part of the KDE project
    SPDX-FileCopyrightText: 2004 Arend van Beelen jr. <arend@auton.nl>
    SPDX-FileCopyrightText: 2010 David Faure <faure@kde.org>

    SPDX-License-Identifier: LGPL-2.0-only
*/

#ifndef KFINDTEST_H
#define KFINDTEST_H

#include <QObject>
#include <QStringList>
#include <ktextwidgets_export.h>
#include <memory>
class KFind;
class KFindRecorder : public QObject
{
    Q_OBJECT

public:
    explicit KFindRecorder(const QStringList &text);

    ~KFindRecorder() override;
    void find(const QString &pattern, long options = 0);
    bool findNext(const QString &pattern = QString());

    void changeText(int line, const QString &text);

    const QStringList &hits() const
    {
        return m_hits;
    }
    void clearHits()
    {
        m_hits.clear();
    }

public Q_SLOTS:
    void slotHighlight(const QString &text, int index, int matchedLength);
    void slotHighlight(int id, int index, int matchedLengthlength);

private:
    std::unique_ptr<KFind> m_find;
    QStringList m_text;
    int m_line;
    QStringList m_hits;
};

class TestKFind : public QObject
{
    Q_OBJECT

public:
    TestKFind();

private Q_SLOTS:

    void testStaticFindRegexp_data();
    void testStaticFindRegexp();

    void testRegexpUnicode_data();
    void testRegexpUnicode();

    void testSimpleSearch();
    void testSimpleRegexp();

    void testLineBeginRegularExpression();
    void testFindIncremental();
    void testFindIncrementalDynamic();

private:
    QString m_text;
};

#endif