Kate
katewildcardmatcher_test.cpp
Go to the documentation of this file.
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2007 Sebastian Pipping <webmaster@hartwork.org> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License version 2 as published by the Free Software Foundation. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Library General Public License for more details. 00012 00013 You should have received a copy of the GNU Library General Public License 00014 along with this library; see the file COPYING.LIB. If not, write to 00015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00016 Boston, MA 02110-1301, USA. 00017 */ 00018 00019 #include "../katewildcardmatcher.h" 00020 #include <QtGlobal> 00021 #include <QtDebug> 00022 00023 00024 00025 bool testCase(const char * candidate, const char * wildcard) { 00026 qDebug("\"%s\" / \"%s\"", candidate, wildcard); 00027 return KateWildcardMatcher::exactMatch(QString(candidate), QString(wildcard)); 00028 } 00029 00030 00031 00032 int main() { 00033 Q_ASSERT(testCase("abc.txt", "*.txt")); 00034 Q_ASSERT(!testCase("abc.txt", "*.cpp")); 00035 00036 Q_ASSERT(testCase("Makefile.am", "*Makefile*")); 00037 00038 Q_ASSERT(testCase("control", "control")); 00039 00040 Q_ASSERT(testCase("abcd", "a??d")); 00041 00042 Q_ASSERT(testCase("a", "?")); 00043 Q_ASSERT(testCase("a", "*?*")); 00044 Q_ASSERT(testCase("a", "*")); 00045 Q_ASSERT(testCase("a", "**")); 00046 Q_ASSERT(testCase("a", "***")); 00047 00048 Q_ASSERT(testCase("", "*")); 00049 Q_ASSERT(testCase("", "**")); 00050 Q_ASSERT(!testCase("", "?")); 00051 00052 Q_ASSERT(testCase("ab", "a*")); 00053 Q_ASSERT(testCase("ab", "*b")); 00054 Q_ASSERT(testCase("ab", "a?")); 00055 Q_ASSERT(testCase("ab", "?b")); 00056 00057 Q_ASSERT(testCase("aXXbXXbYYaYc", "a*b*c")); 00058 00059 00060 qDebug() << endl << "DONE"; 00061 return 0; 00062 } 00063
KDE 4.6 API Reference