]>
git.saurik.com Git - apt.git/blob - test/libapt/getlistoffilesindir_test.cc
1 #include <apt-pkg/fileutl.h>
10 // simple helper to quickly output a vector of strings
11 void dumpVector(std::vector
<std::string
> vec
) {
12 for (std::vector
<std::string
>::const_iterator v
= vec
.begin();
14 std::cout
<< *v
<< std::endl
;
17 #define P(x) string(argv[1]).append("/").append(x)
19 int main(int argc
,char *argv
[])
22 std::cout
<< "One parameter expected - given " << argc
<< std::endl
;
26 // Files with no extension
27 std::vector
<std::string
> files
= GetListOfFilesInDir(argv
[1], "", true);
28 equals(files
.size(), 2);
29 equals(files
[0], P("01yet-anothernormalfile"));
30 equals(files
[1], P("anormalfile"));
32 // Files with no extension - should be the same as above
33 files
= GetListOfFilesInDir(argv
[1], "", true, true);
34 equals(files
.size(), 2);
35 equals(files
[0], P("01yet-anothernormalfile"));
36 equals(files
[1], P("anormalfile"));
38 // Files with impossible extension
39 files
= GetListOfFilesInDir(argv
[1], "impossible", true);
40 equals(files
.size(), 0);
42 // Files with impossible or no extension
43 files
= GetListOfFilesInDir(argv
[1], "impossible", true, true);
44 equals(files
.size(), 2);
45 equals(files
[0], P("01yet-anothernormalfile"));
46 equals(files
[1], P("anormalfile"));
48 // Files with list extension - nothing more
49 files
= GetListOfFilesInDir(argv
[1], "list", true);
50 equals(files
.size(), 4);
51 equals(files
[0], P("01yet-anotherapt.list"));
52 equals(files
[1], P("anormalapt.list"));
53 equals(files
[2], P("linkedfile.list"));
54 equals(files
[3], P("multi.dot.list"));
56 // Files with conf or no extension
57 files
= GetListOfFilesInDir(argv
[1], "conf", true, true);
58 equals(files
.size(), 5);
59 equals(files
[0], P("01yet-anotherapt.conf"));
60 equals(files
[1], P("01yet-anothernormalfile"));
61 equals(files
[2], P("anormalapt.conf"));
62 equals(files
[3], P("anormalfile"));
63 equals(files
[4], P("multi.dot.conf"));
65 // Files with disabled extension - nothing more
66 files
= GetListOfFilesInDir(argv
[1], "disabled", true);
67 equals(files
.size(), 3);
68 equals(files
[0], P("disabledfile.conf.disabled"));
69 equals(files
[1], P("disabledfile.disabled"));
70 equals(files
[2], P("disabledfile.list.disabled"));
72 // Files with disabled or no extension
73 files
= GetListOfFilesInDir(argv
[1], "disabled", true, true);
74 equals(files
.size(), 5);
75 equals(files
[0], P("01yet-anothernormalfile"));
76 equals(files
[1], P("anormalfile"));
77 equals(files
[2], P("disabledfile.conf.disabled"));
78 equals(files
[3], P("disabledfile.disabled"));
79 equals(files
[4], P("disabledfile.list.disabled"));