]>
Commit | Line | Data |
---|---|---|
453b82a3 DK |
1 | #include <config.h> |
2 | ||
b39c1859 MV |
3 | #include <apt-pkg/fileutl.h> |
4 | ||
b39c1859 MV |
5 | #include <string> |
6 | #include <vector> | |
b39c1859 MV |
7 | #include <iostream> |
8 | ||
453b82a3 DK |
9 | #include "assert.h" |
10 | ||
8f3ba4e8 | 11 | #define P(x) std::string(argv[1]).append("/").append(x) |
b39c1859 MV |
12 | |
13 | int main(int argc,char *argv[]) | |
14 | { | |
15 | if (argc != 2) { | |
16 | std::cout << "One parameter expected - given " << argc << std::endl; | |
17 | return 100; | |
18 | } | |
19 | ||
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")); | |
25 | ||
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")); | |
31 | ||
32 | // Files with impossible extension | |
33 | files = GetListOfFilesInDir(argv[1], "impossible", true); | |
34 | equals(files.size(), 0); | |
35 | ||
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")); | |
41 | ||
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")); | |
49 | ||
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")); | |
58 | ||
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")); | |
65 | ||
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")); | |
74 | ||
75 | return 0; | |
76 | } |