23 #include "testfilesearchpath.h"
25 #include "pathfinder/filesearchpath.h"
27 #define ASSERT(x) { if (!(x)) { testLog << "Failed: ASSERT(" #x ")"; return false; }}
28 #define ASSERT_FALSE(x) { if (x) { testLog << "Failed: ASSERT_FALSE(" #x ")"; return false;}}
30 bool TestFileSearchPathContains::executeTest()
33 ASSERT(simplePath.contains(
"avo/ca"));
34 ASSERT(simplePath.contains(
"avo/ca/"));
35 ASSERT(simplePath.contains(
"avo//ca//"));
36 ASSERT_FALSE(simplePath.contains(
"avo/c"));
37 ASSERT_FALSE(simplePath.contains(
"avo/cado"));
38 ASSERT_FALSE(simplePath.contains(
"avo/ca/do"));
39 ASSERT_FALSE(simplePath.contains(
"avo"));
41 ASSERT(simplePath.contains(
"avo\\ca"));
42 ASSERT(simplePath.contains(
"avo\\ca\\"));
43 ASSERT_FALSE(simplePath.contains(
"avo\\ca\\do"));
44 ASSERT_FALSE(simplePath.contains(
"avo\\cado"));
48 recursivePath.setRecursive(
true);
49 ASSERT(recursivePath.contains(
"avo/ca"));
50 ASSERT(recursivePath.contains(
"avo/ca/"));
51 ASSERT(recursivePath.contains(
"avo//ca//"));
52 ASSERT_FALSE(recursivePath.contains(
"avo/c"));
53 ASSERT_FALSE(recursivePath.contains(
"avo/cado"));
54 ASSERT(recursivePath.contains(
"avo/ca/do"));
55 ASSERT_FALSE(recursivePath.contains(
"avo"));
57 ASSERT(recursivePath.contains(
"avo\\ca"));
58 ASSERT(recursivePath.contains(
"avo\\ca\\"));
59 ASSERT(recursivePath.contains(
"avo\\ca\\do"));
60 ASSERT_FALSE(recursivePath.contains(
"avo\\cado"));
66 bool TestFileSearchPathMerge::executeTest()
69 QList<FileSearchPath> paths;
74 paths << []() {
FileSearchPath p(
"ba/na"); p.setRecursive(
true);
return p; }();
75 paths << []() {
FileSearchPath p(
"ap"); p.setRecursive(
true);
return p; }();
76 paths << []() {
FileSearchPath p(
"ap/ple"); p.setRecursive(
true);
return p; }();
78 paths << []() {
FileSearchPath p(
"recuA"); p.setRecursive(
true);
return p; }();
79 paths << []() {
FileSearchPath p(
"recuB"); p.setRecursive(
true);
return p; }();
86 testLog << QString(
"paths.length() == %1").arg(paths.length());
87 for (
int idx = 0; idx < paths.length(); ++idx)
89 testLog << QString(
"paths[%1]: %2%3")
91 .arg(paths[idx].path())
92 .arg(paths[idx].isRecursive() ?
" (R)" :
"");
94 ASSERT(paths.length() == 6);
95 ASSERT(paths[0].path() ==
"avo/ca/");
96 ASSERT_FALSE(paths[0].isRecursive());
97 ASSERT(paths[1].path() ==
"avo/ca/do");
98 ASSERT_FALSE(paths[1].isRecursive());
99 ASSERT(paths[2].path() ==
"ba/na");
100 ASSERT(paths[2].isRecursive());
101 ASSERT(paths[3].path() ==
"ap");
102 ASSERT(paths[3].isRecursive());
103 ASSERT(paths[4].path() ==
"recuA");
104 ASSERT(paths[4].isRecursive());
105 ASSERT(paths[5].path() ==
"recuB");
106 ASSERT(paths[5].isRecursive());