• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • applications API Reference
  • KDE Home
  • Contact Us
 

Kate

  • kde-4.14
  • applications
  • kate
  • part
  • mode
  • testing
katewildcardmatcher_test.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE libraries
2  Copyright (C) 2007 Sebastian Pipping <webmaster@hartwork.org>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 */
18 
19 #include "../katewildcardmatcher.h"
20 #include <QtGlobal>
21 #include <QtDebug>
22 
23 
24 
25 bool testCase(const char * candidate, const char * wildcard) {
26  qDebug("\"%s\" / \"%s\"", candidate, wildcard);
27  return KateWildcardMatcher::exactMatch(QString(candidate), QString(wildcard));
28 }
29 
30 
31 
32 int main() {
33  Q_ASSERT(testCase("abc.txt", "*.txt"));
34  Q_ASSERT(!testCase("abc.txt", "*.cpp"));
35 
36  Q_ASSERT(testCase("Makefile.am", "*Makefile*"));
37 
38  Q_ASSERT(testCase("control", "control"));
39 
40  Q_ASSERT(testCase("abcd", "a??d"));
41 
42  Q_ASSERT(testCase("a", "?"));
43  Q_ASSERT(testCase("a", "*?*"));
44  Q_ASSERT(testCase("a", "*"));
45  Q_ASSERT(testCase("a", "**"));
46  Q_ASSERT(testCase("a", "***"));
47 
48  Q_ASSERT(testCase("", "*"));
49  Q_ASSERT(testCase("", "**"));
50  Q_ASSERT(!testCase("", "?"));
51 
52  Q_ASSERT(testCase("ab", "a*"));
53  Q_ASSERT(testCase("ab", "*b"));
54  Q_ASSERT(testCase("ab", "a?"));
55  Q_ASSERT(testCase("ab", "?b"));
56 
57  Q_ASSERT(testCase("aXXbXXbYYaYc", "a*b*c"));
58 
59 
60  qDebug() << endl << "DONE";
61  return 0;
62 }
63 
KateWildcardMatcher::exactMatch
bool exactMatch(const QString &candidate, const QString &wildcard, int candidatePosFromRight, int wildcardPosFromRight, bool caseSensitive=true)
Definition: katewildcardmatcher.cpp:29
QString
testCase
bool testCase(const char *candidate, const char *wildcard)
Definition: katewildcardmatcher_test.cpp:25
main
int main()
Definition: katewildcardmatcher_test.cpp:32
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:59 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Kate

Skip menu "Kate"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Konsole

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal