]>
git.saurik.com Git - apt.git/blob - test/libapt/configuration_test.cc
1 #include <apt-pkg/configuration.h>
8 int main(int argc
,const char *argv
[]) {
10 std::vector
<std::string
> fds
;
12 Cnf
.Set("APT::Keep-Fds::",28);
13 Cnf
.Set("APT::Keep-Fds::",17);
14 Cnf
.Set("APT::Keep-Fds::2",47);
15 Cnf
.Set("APT::Keep-Fds::","broken");
16 fds
= Cnf
.FindVector("APT::Keep-Fds");
20 equals(fds
[3], "broken");
21 equals(fds
.size(), 4);
22 equals(Cnf
.Exists("APT::Keep-Fds::2"), true);
23 equals(Cnf
.Find("APT::Keep-Fds::2"), "47");
24 equals(Cnf
.FindI("APT::Keep-Fds::2"), 47);
25 equals(Cnf
.Exists("APT::Keep-Fds::3"), false);
26 equals(Cnf
.Find("APT::Keep-Fds::3"), "");
27 equals(Cnf
.FindI("APT::Keep-Fds::3", 56), 56);
28 equals(Cnf
.Find("APT::Keep-Fds::3", "not-set"), "not-set");
30 Cnf
.Clear("APT::Keep-Fds::2");
31 fds
= Cnf
.FindVector("APT::Keep-Fds");
35 equals(fds
[3], "broken");
36 equals(fds
.size(), 4);
37 equals(Cnf
.Exists("APT::Keep-Fds::2"), true);
39 Cnf
.Clear("APT::Keep-Fds",28);
40 fds
= Cnf
.FindVector("APT::Keep-Fds");
43 equals(fds
[2], "broken");
44 equals(fds
.size(), 3);
46 Cnf
.Clear("APT::Keep-Fds","");
47 equals(Cnf
.Exists("APT::Keep-Fds::2"), false);
49 Cnf
.Clear("APT::Keep-Fds",17);
50 Cnf
.Clear("APT::Keep-Fds","broken");
51 fds
= Cnf
.FindVector("APT::Keep-Fds");
52 equals(fds
.empty(), true);
54 Cnf
.Set("APT::Keep-Fds::",21);
55 Cnf
.Set("APT::Keep-Fds::",42);
56 fds
= Cnf
.FindVector("APT::Keep-Fds");
59 equals(fds
.size(), 2);
61 Cnf
.Clear("APT::Keep-Fds");
62 fds
= Cnf
.FindVector("APT::Keep-Fds");
63 equals(fds
.empty(), true);
65 Cnf
.CndSet("APT::Version", 42);
66 Cnf
.CndSet("APT::Version", "66");
67 equals(Cnf
.Find("APT::Version"), "42");
68 equals(Cnf
.FindI("APT::Version"), 42);
69 equals(Cnf
.Find("APT::Version", "33"), "42");
70 equals(Cnf
.FindI("APT::Version", 33), 42);
71 equals(Cnf
.Find("APT2::Version", "33"), "33");
72 equals(Cnf
.FindI("APT2::Version", 33), 33);
74 equals(Cnf
.FindFile("Dir::State"), "");
75 equals(Cnf
.FindFile("Dir::Aptitude::State"), "");
76 Cnf
.Set("Dir", "/srv/sid");
77 equals(Cnf
.FindFile("Dir::State"), "");
78 Cnf
.Set("Dir::State", "var/lib/apt");
79 Cnf
.Set("Dir::Aptitude::State", "var/lib/aptitude");
80 equals(Cnf
.FindFile("Dir::State"), "/srv/sid/var/lib/apt");
81 equals(Cnf
.FindFile("Dir::Aptitude::State"), "/srv/sid/var/lib/aptitude");
83 Cnf
.Set("RootDir", "/");
84 equals(Cnf
.FindFile("Dir::State"), "/srv/sid/var/lib/apt");
85 equals(Cnf
.FindFile("Dir::Aptitude::State"), "/srv/sid/var/lib/aptitude");
86 Cnf
.Set("RootDir", "//./////.////");
87 equals(Cnf
.FindFile("Dir::State"), "/srv/sid/var/lib/apt");
88 equals(Cnf
.FindFile("Dir::Aptitude::State"), "/srv/sid/var/lib/aptitude");
89 Cnf
.Set("RootDir", "/rootdir");
90 equals(Cnf
.FindFile("Dir::State"), "/rootdir/srv/sid/var/lib/apt");
91 equals(Cnf
.FindFile("Dir::Aptitude::State"), "/rootdir/srv/sid/var/lib/aptitude");
92 Cnf
.Set("RootDir", "/rootdir/");
93 equals(Cnf
.FindFile("Dir::State"), "/rootdir/srv/sid/var/lib/apt");
94 equals(Cnf
.FindFile("Dir::Aptitude::State"), "/rootdir/srv/sid/var/lib/aptitude");
96 Cnf
.Set("Dir::State", "/dev/null");
97 Cnf
.Set("Dir::State::lists", "lists/");
98 equals(Cnf
.FindDir("Dir::State"), "/rootdir/dev/null");
99 equals(Cnf
.FindDir("Dir::State::lists"), "/rootdir/dev/null");
101 Cnf
.Set("Moo::Bar", "1");
103 equals(Cnf
.Find("Moo::Bar"), "");
105 //FIXME: Test for configuration file parsing;
106 // currently only integration/ tests test them implicitly