]>
git.saurik.com Git - apt.git/blob - test/libapt/getlistoffilesindir_test.cc
3 #include <apt-pkg/fileutl.h>
11 #define P(x) std::string(argv[1]).append("/").append(x)
13 int main(int argc
,char *argv
[])
16 std::cout
<< "One parameter expected - given " << argc
<< std::endl
;
20 // Files with no extension
21 std::vector
<std::string
> files
= GetListOfFilesInDir(argv
[1], "", true);
22 equals(files
.size(), 2);
23 equals(files
[0], P("01yet-anothernormalfile"));
24 equals(files
[1], P("anormalfile"));
26 // Files with no extension - should be the same as above
27 files
= GetListOfFilesInDir(argv
[1], "", true, true);
28 equals(files
.size(), 2);
29 equals(files
[0], P("01yet-anothernormalfile"));
30 equals(files
[1], P("anormalfile"));
32 // Files with impossible extension
33 files
= GetListOfFilesInDir(argv
[1], "impossible", true);
34 equals(files
.size(), 0);
36 // Files with impossible or no extension
37 files
= GetListOfFilesInDir(argv
[1], "impossible", true, true);
38 equals(files
.size(), 2);
39 equals(files
[0], P("01yet-anothernormalfile"));
40 equals(files
[1], P("anormalfile"));
42 // Files with list extension - nothing more
43 files
= GetListOfFilesInDir(argv
[1], "list", true);
44 equals(files
.size(), 4);
45 equals(files
[0], P("01yet-anotherapt.list"));
46 equals(files
[1], P("anormalapt.list"));
47 equals(files
[2], P("linkedfile.list"));
48 equals(files
[3], P("multi.dot.list"));
50 // Files with conf or no extension
51 files
= GetListOfFilesInDir(argv
[1], "conf", true, true);
52 equals(files
.size(), 5);
53 equals(files
[0], P("01yet-anotherapt.conf"));
54 equals(files
[1], P("01yet-anothernormalfile"));
55 equals(files
[2], P("anormalapt.conf"));
56 equals(files
[3], P("anormalfile"));
57 equals(files
[4], P("multi.dot.conf"));
59 // Files with disabled extension - nothing more
60 files
= GetListOfFilesInDir(argv
[1], "disabled", true);
61 equals(files
.size(), 3);
62 equals(files
[0], P("disabledfile.conf.disabled"));
63 equals(files
[1], P("disabledfile.disabled"));
64 equals(files
[2], P("disabledfile.list.disabled"));
66 // Files with disabled or no extension
67 files
= GetListOfFilesInDir(argv
[1], "disabled", true, true);
68 equals(files
.size(), 5);
69 equals(files
[0], P("01yet-anothernormalfile"));
70 equals(files
[1], P("anormalfile"));
71 equals(files
[2], P("disabledfile.conf.disabled"));
72 equals(files
[3], P("disabledfile.disabled"));
73 equals(files
[4], P("disabledfile.list.disabled"));