]>
git.saurik.com Git - apt.git/blob - test/libapt/cdromfindpackages_test.cc
3 #include <apt-pkg/cdrom.h>
4 #include <apt-pkg/error.h>
14 class Cdrom
: public pkgCdrom
{
16 bool FindPackages(std::string
const &CD
,
17 std::vector
<std::string
> &List
,
18 std::vector
<std::string
> &SList
,
19 std::vector
<std::string
> &SigList
,
20 std::vector
<std::string
> &TransList
,
21 std::string
&InfoDir
) {
22 bool const result
= pkgCdrom::FindPackages(CD
, List
, SList
, SigList
, TransList
, InfoDir
, NULL
, 0);
23 std::sort(List
.begin(), List
.end());
24 std::sort(SList
.begin(), SList
.end());
25 std::sort(SigList
.begin(), SigList
.end());
26 std::sort(TransList
.begin(), TransList
.end());
30 bool DropRepeats(std::vector
<std::string
> &List
, char const *Name
) {
31 return pkgCdrom::DropRepeats(List
, Name
);
35 int main(int argc
, char const *argv
[]) {
37 std::cout
<< "One parameter expected - given " << argc
<< std::endl
;
42 std::vector
<std::string
> Packages
, Sources
, Signatur
, Translation
;
44 std::string path
= argv
[1];
45 equals(true, cd
.FindPackages(path
, Packages
, Sources
, Signatur
, Translation
, InfoDir
));
46 equals(4, Packages
.size());
47 equals(path
+ "/dists/sid/main/binary-i386/", Packages
[0]);
48 equals(path
+ "/dists/stable/contrib/binary-amd64/", Packages
[1]);
49 equals(path
+ "/dists/stable/main/binary-i386/", Packages
[2]);
50 equals(path
+ "/dists/unstable/main/binary-i386/", Packages
[3]);
51 equals(3, Sources
.size());
52 equals(path
+ "/dists/sid/main/source/", Sources
[0]);
53 equals(path
+ "/dists/stable/main/source/", Sources
[1]);
54 equals(path
+ "/dists/unstable/main/source/", Sources
[2]);
55 equals(3, Signatur
.size());
56 equals(path
+ "/dists/sid/", Signatur
[0]);
57 equals(path
+ "/dists/stable/", Signatur
[1]);
58 equals(path
+ "/dists/unstable/", Signatur
[2]);
59 equals(4, Translation
.size());
60 equals(path
+ "/dists/sid/main/i18n/Translation-de", Translation
[0]);
61 equals(path
+ "/dists/sid/main/i18n/Translation-en", Translation
[1]);
62 equals(path
+ "/dists/unstable/main/i18n/Translation-de", Translation
[2]);
63 equals(path
+ "/dists/unstable/main/i18n/Translation-en", Translation
[3]);
64 equals(path
+ "/.disk/", InfoDir
);
66 cd
.DropRepeats(Packages
, "Packages");
67 cd
.DropRepeats(Sources
, "Sources");
68 _error
->PushToStack();
69 cd
.DropRepeats(Signatur
, "InRelease");
70 cd
.DropRepeats(Signatur
, "Release.gpg");
71 _error
->RevertToStack();
73 cd
.DropRepeats(Translation
, "");
75 equals(3, Packages
.size());
76 equals(path
+ "/dists/stable/contrib/binary-amd64/", Packages
[0]);
77 equals(path
+ "/dists/stable/main/binary-i386/", Packages
[1]);
78 equals(path
+ "/dists/unstable/main/binary-i386/", Packages
[2]);
79 equals(2, Sources
.size());
80 equals(path
+ "/dists/stable/main/source/", Sources
[0]);
81 equals(path
+ "/dists/unstable/main/source/", Sources
[1]);
82 equals(2, Signatur
.size());
83 equals(path
+ "/dists/stable/", Signatur
[0]);
84 equals(path
+ "/dists/unstable/", Signatur
[1]);
85 equals(2, Translation
.size());
86 equals(path
+ "/dists/unstable/main/i18n/Translation-de", Translation
[0]);
87 equals(path
+ "/dists/unstable/main/i18n/Translation-en", Translation
[1]);