Changeset View
Changeset View
Standalone View
Standalone View
addons/tabswitcher/autotests/tabswitchertest.cpp
- This file was added.
1 | /* This file is part of the KDE project | ||||
---|---|---|---|---|---|
2 | * | ||||
3 | * Copyright (C) 2018 Gregor Mi <codestruct@posteo.org> | ||||
4 | * | ||||
5 | * This library is free software; you can redistribute it and/or | ||||
6 | * modify it under the terms of the GNU Library General Public | ||||
7 | * License as published by the Free Software Foundation; either | ||||
8 | * version 2 of the License, or (at your option) any later version. | ||||
9 | * | ||||
10 | * This library is distributed in the hope that it will be useful, | ||||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
13 | * Library General Public License for more details. | ||||
14 | * | ||||
15 | * You should have received a copy of the GNU Library General Public License | ||||
16 | * along with this library; see the file COPYING.LIB. If not, write to | ||||
17 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||||
18 | * Boston, MA 02110-1301, USA. | ||||
19 | */ | ||||
20 | | ||||
21 | #include "tabswitchertest.h" | ||||
22 | #include "tabswitcherfilesmodel.h" | ||||
23 | | ||||
24 | #include <QTest> | ||||
25 | | ||||
26 | QTEST_MAIN(KateTabSwitcherTest) | ||||
27 | | ||||
28 | void KateTabSwitcherTest::initTestCase() | ||||
29 | { | ||||
30 | } | ||||
31 | | ||||
32 | void KateTabSwitcherTest::cleanupTestCase() | ||||
33 | { | ||||
34 | } | ||||
35 | | ||||
36 | void KateTabSwitcherTest::testLongestCommonPrefix() | ||||
37 | { | ||||
38 | // standard case | ||||
39 | std::vector<QString> strs; | ||||
40 | strs.push_back(QLatin1String("/home/user1/a")); | ||||
41 | strs.push_back(QLatin1String("/home/user1/bc")); | ||||
42 | QCOMPARE(detail::longestCommonPrefix(strs), QLatin1String("/home/user1/")); | ||||
43 | | ||||
44 | // empty string at the end of the list | ||||
45 | strs.clear(); | ||||
46 | strs.push_back(QLatin1String("/home/a")); | ||||
47 | strs.push_back(QLatin1String("/home/b")); | ||||
48 | strs.push_back(QLatin1String("")); | ||||
49 | QCOMPARE(detail::longestCommonPrefix(strs), QLatin1String("")); | ||||
50 | | ||||
51 | // empty string not only at the end of the list | ||||
52 | strs.clear(); | ||||
53 | strs.push_back(QLatin1String("")); | ||||
54 | strs.push_back(QLatin1String("/home/a")); | ||||
55 | strs.push_back(QLatin1String("/home/b")); | ||||
56 | strs.push_back(QLatin1String("")); | ||||
57 | QCOMPARE(detail::longestCommonPrefix(strs), QLatin1String("")); | ||||
58 | | ||||
59 | // a prefix with length 1 | ||||
60 | strs.clear(); | ||||
61 | strs.push_back(QLatin1String("/home/a")); | ||||
62 | strs.push_back(QLatin1String("/etc/b")); | ||||
63 | QCOMPARE(detail::longestCommonPrefix(strs), QLatin1String("/")); | ||||
64 | } |