]> git.saurik.com Git - apt.git/blob - test/libapt/cdromfindpackages_test.cc
trigger the usage of the fallback code for kfreebsd also in the
[apt.git] / test / libapt / cdromfindpackages_test.cc
1 #include <apt-pkg/cdrom.h>
2 #include <apt-pkg/error.h>
3
4 #include <algorithm>
5 #include <string>
6 #include <vector>
7
8 #include "assert.h"
9
10 class Cdrom : public pkgCdrom {
11 public:
12 bool FindPackages(std::string const &CD,
13 std::vector<std::string> &List,
14 std::vector<std::string> &SList,
15 std::vector<std::string> &SigList,
16 std::vector<std::string> &TransList,
17 std::string &InfoDir) {
18 bool const result = pkgCdrom::FindPackages(CD, List, SList, SigList, TransList, InfoDir, NULL, 0);
19 std::sort(List.begin(), List.end());
20 std::sort(SList.begin(), SList.end());
21 std::sort(SigList.begin(), SigList.end());
22 std::sort(TransList.begin(), TransList.end());
23 return result;
24 }
25
26 bool DropRepeats(std::vector<std::string> &List, char const *Name) {
27 return pkgCdrom::DropRepeats(List, Name);
28 }
29 };
30
31 int main(int argc, char const *argv[]) {
32 if (argc != 2) {
33 std::cout << "One parameter expected - given " << argc << std::endl;
34 return 100;
35 }
36
37 Cdrom cd;
38 std::vector<std::string> Packages, Sources, Signatur, Translation;
39 std::string InfoDir;
40 std::string path = argv[1];
41 equals(true, cd.FindPackages(path, Packages, Sources, Signatur, Translation, InfoDir));
42 equals(4, Packages.size());
43 equals(path + "/dists/sid/main/binary-i386/", Packages[0]);
44 equals(path + "/dists/stable/contrib/binary-amd64/", Packages[1]);
45 equals(path + "/dists/stable/main/binary-i386/", Packages[2]);
46 equals(path + "/dists/unstable/main/binary-i386/", Packages[3]);
47 equals(3, Sources.size());
48 equals(path + "/dists/sid/main/source/", Sources[0]);
49 equals(path + "/dists/stable/main/source/", Sources[1]);
50 equals(path + "/dists/unstable/main/source/", Sources[2]);
51 equals(3, Signatur.size());
52 equals(path + "/dists/sid/", Signatur[0]);
53 equals(path + "/dists/stable/", Signatur[1]);
54 equals(path + "/dists/unstable/", Signatur[2]);
55 equals(4, Translation.size());
56 equals(path + "/dists/sid/main/i18n/Translation-de", Translation[0]);
57 equals(path + "/dists/sid/main/i18n/Translation-en", Translation[1]);
58 equals(path + "/dists/unstable/main/i18n/Translation-de", Translation[2]);
59 equals(path + "/dists/unstable/main/i18n/Translation-en", Translation[3]);
60 equals(path + "/.disk/", InfoDir);
61
62 cd.DropRepeats(Packages, "Packages");
63 cd.DropRepeats(Sources, "Sources");
64 _error->PushToStack();
65 cd.DropRepeats(Signatur, "InRelease");
66 cd.DropRepeats(Signatur, "Release.gpg");
67 _error->RevertToStack();
68 _error->DumpErrors();
69 cd.DropRepeats(Translation, "");
70
71 equals(3, Packages.size());
72 equals(path + "/dists/stable/contrib/binary-amd64/", Packages[0]);
73 equals(path + "/dists/stable/main/binary-i386/", Packages[1]);
74 equals(path + "/dists/unstable/main/binary-i386/", Packages[2]);
75 equals(2, Sources.size());
76 equals(path + "/dists/stable/main/source/", Sources[0]);
77 equals(path + "/dists/unstable/main/source/", Sources[1]);
78 equals(2, Signatur.size());
79 equals(path + "/dists/stable/", Signatur[0]);
80 equals(path + "/dists/unstable/", Signatur[1]);
81 equals(2, Translation.size());
82 equals(path + "/dists/unstable/main/i18n/Translation-de", Translation[0]);
83 equals(path + "/dists/unstable/main/i18n/Translation-en", Translation[1]);
84
85 return 0;
86 }