Changeset View
Changeset View
Standalone View
Standalone View
src/tests/directoryfindchilditemtest.cpp
- This file was added.
1 | /*************************************************************************** | ||||
---|---|---|---|---|---|
2 | * Copyright (C) 2018 by Emirald Mateli <aldo.mateli@gmail.com> * | ||||
3 | * * | ||||
4 | * This program is free software; you can redistribute it and/or modify * | ||||
5 | * it under the terms of the GNU General Public License as published by * | ||||
6 | * the Free Software Foundation; either version 2 of the License, or * | ||||
7 | * (at your option) any later version. * | ||||
8 | * * | ||||
9 | * This program is distributed in the hope that it will be useful, * | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||||
12 | * GNU General Public License for more details. * | ||||
13 | * * | ||||
14 | * You should have received a copy of the GNU General Public License * | ||||
15 | * along with this program; if not, write to the * | ||||
16 | * Free Software Foundation, Inc., * | ||||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * | ||||
18 | ***************************************************************************/ | ||||
19 | | ||||
20 | #include "utils/directoryfindchilditem.cpp" | ||||
21 | #include <QTest> | ||||
22 | | ||||
23 | class DirectoryFindChildItemTest : public QObject | ||||
24 | { | ||||
25 | Q_OBJECT | ||||
26 | | ||||
27 | private slots: | ||||
28 | void testDirectoryFindChildItem_data(); | ||||
29 | void testDirectoryFindChildItem(); | ||||
30 | }; | ||||
31 | | ||||
32 | void DirectoryFindChildItemTest::testDirectoryFindChildItem_data() | ||||
33 | { | ||||
34 | QTest::addColumn<QUrl>("directory"); | ||||
35 | QTest::addColumn<QUrl>("url"); | ||||
36 | QTest::addColumn<QUrl>("expected"); | ||||
37 | | ||||
38 | QTest::newRow("Test directory with file located in one of its children") | ||||
39 | << QUrl::fromLocalFile("dir") | ||||
40 | << QUrl::fromLocalFile("dir/sub/x/y/z") | ||||
41 | << QUrl::fromLocalFile("dir/sub"); | ||||
42 | | ||||
43 | QTest::newRow("Test directory with trailing path delimiter") | ||||
44 | << QUrl::fromLocalFile("dir/sub/x/") | ||||
45 | << QUrl::fromLocalFile("dir/sub/x/y/z") | ||||
46 | << QUrl::fromLocalFile("dir/sub/x/y"); | ||||
47 | | ||||
48 | QTest::newRow("Test two unrelated directories") | ||||
49 | << QUrl::fromLocalFile("unrelated") | ||||
50 | << QUrl::fromLocalFile("dir/sub/x/y/z") | ||||
51 | << QUrl(); | ||||
52 | } | ||||
53 | | ||||
54 | void DirectoryFindChildItemTest::testDirectoryFindChildItem() | ||||
55 | { | ||||
56 | QFETCH(QUrl, directory); | ||||
57 | QFETCH(QUrl, url); | ||||
58 | QFETCH(QUrl, expected); | ||||
59 | | ||||
60 | QCOMPARE(directoryFindChildItem(directory, url), expected); | ||||
61 | } | ||||
62 | | ||||
63 | QTEST_MAIN(DirectoryFindChildItemTest) | ||||
64 | | ||||
65 | #include "directoryfindchilditemtest.moc" |