]>
git.saurik.com Git - apt.git/blob - test/libapt/configuration_test.cc
3 #include <apt-pkg/configuration.h>
12 std::vector
<std::string
> fds
;
14 Cnf
.Set("APT::Keep-Fds::",28);
15 Cnf
.Set("APT::Keep-Fds::",17);
16 Cnf
.Set("APT::Keep-Fds::2",47);
17 Cnf
.Set("APT::Keep-Fds::","broken");
18 fds
= Cnf
.FindVector("APT::Keep-Fds");
22 equals(fds
[3], "broken");
23 equals(fds
.size(), 4);
24 equals(Cnf
.Exists("APT::Keep-Fds::2"), true);
25 equals(Cnf
.Find("APT::Keep-Fds::2"), "47");
26 equals(Cnf
.FindI("APT::Keep-Fds::2"), 47);
27 equals(Cnf
.Exists("APT::Keep-Fds::3"), false);
28 equals(Cnf
.Find("APT::Keep-Fds::3"), "");
29 equals(Cnf
.FindI("APT::Keep-Fds::3", 56), 56);
30 equals(Cnf
.Find("APT::Keep-Fds::3", "not-set"), "not-set");
32 Cnf
.Clear("APT::Keep-Fds::2");
33 fds
= Cnf
.FindVector("APT::Keep-Fds");
37 equals(fds
[3], "broken");
38 equals(fds
.size(), 4);
39 equals(Cnf
.Exists("APT::Keep-Fds::2"), true);
41 Cnf
.Clear("APT::Keep-Fds",28);
42 fds
= Cnf
.FindVector("APT::Keep-Fds");
45 equals(fds
[2], "broken");
46 equals(fds
.size(), 3);
48 Cnf
.Clear("APT::Keep-Fds","");
49 equals(Cnf
.Exists("APT::Keep-Fds::2"), false);
51 Cnf
.Clear("APT::Keep-Fds",17);
52 Cnf
.Clear("APT::Keep-Fds","broken");
53 fds
= Cnf
.FindVector("APT::Keep-Fds");
54 equals(fds
.empty(), true);
56 Cnf
.Set("APT::Keep-Fds::",21);
57 Cnf
.Set("APT::Keep-Fds::",42);
58 fds
= Cnf
.FindVector("APT::Keep-Fds");
61 equals(fds
.size(), 2);
63 Cnf
.Clear("APT::Keep-Fds");
64 fds
= Cnf
.FindVector("APT::Keep-Fds");
65 equals(fds
.empty(), true);
67 Cnf
.CndSet("APT::Version", 42);
68 Cnf
.CndSet("APT::Version", "66");
69 equals(Cnf
.Find("APT::Version"), "42");
70 equals(Cnf
.FindI("APT::Version"), 42);
71 equals(Cnf
.Find("APT::Version", "33"), "42");
72 equals(Cnf
.FindI("APT::Version", 33), 42);
73 equals(Cnf
.Find("APT2::Version", "33"), "33");
74 equals(Cnf
.FindI("APT2::Version", 33), 33);
76 equals(Cnf
.FindFile("Dir::State"), "");
77 equals(Cnf
.FindFile("Dir::Aptitude::State"), "");
78 Cnf
.Set("Dir", "/srv/sid");
79 equals(Cnf
.FindFile("Dir::State"), "");
80 Cnf
.Set("Dir::State", "var/lib/apt");
81 Cnf
.Set("Dir::Aptitude::State", "var/lib/aptitude");
82 equals(Cnf
.FindFile("Dir::State"), "/srv/sid/var/lib/apt");
83 equals(Cnf
.FindFile("Dir::Aptitude::State"), "/srv/sid/var/lib/aptitude");
85 Cnf
.Set("RootDir", "/");
86 equals(Cnf
.FindFile("Dir::State"), "/srv/sid/var/lib/apt");
87 equals(Cnf
.FindFile("Dir::Aptitude::State"), "/srv/sid/var/lib/aptitude");
88 Cnf
.Set("RootDir", "//./////.////");
89 equals(Cnf
.FindFile("Dir::State"), "/srv/sid/var/lib/apt");
90 equals(Cnf
.FindFile("Dir::Aptitude::State"), "/srv/sid/var/lib/aptitude");
91 Cnf
.Set("RootDir", "/rootdir");
92 equals(Cnf
.FindFile("Dir::State"), "/rootdir/srv/sid/var/lib/apt");
93 equals(Cnf
.FindFile("Dir::Aptitude::State"), "/rootdir/srv/sid/var/lib/aptitude");
94 Cnf
.Set("RootDir", "/rootdir/");
95 equals(Cnf
.FindFile("Dir::State"), "/rootdir/srv/sid/var/lib/apt");
96 equals(Cnf
.FindFile("Dir::Aptitude::State"), "/rootdir/srv/sid/var/lib/aptitude");
98 Cnf
.Set("Dir::State", "/dev/null");
99 Cnf
.Set("Dir::State::lists", "lists/");
100 equals(Cnf
.FindDir("Dir::State"), "/rootdir/dev/null");
101 equals(Cnf
.FindDir("Dir::State::lists"), "/rootdir/dev/null");
103 Cnf
.Set("Moo::Bar", "1");
105 equals(Cnf
.Find("Moo::Bar"), "");
107 std::vector
<std::string
> vec
= Cnf
.FindVector("Test::Vector", "");
108 equals(vec
.size(), 0);
109 vec
= Cnf
.FindVector("Test::Vector", "foo");
110 equals(vec
.size(), 1);
111 equals(vec
[0], "foo");
112 vec
= Cnf
.FindVector("Test::Vector", "foo,bar");
113 equals(vec
.size(), 2);
114 equals(vec
[0], "foo");
115 equals(vec
[1], "bar");
116 Cnf
.Set("Test::Vector::", "baz");
117 Cnf
.Set("Test::Vector::", "bob");
118 Cnf
.Set("Test::Vector::", "dob");
119 vec
= Cnf
.FindVector("Test::Vector");
120 equals(vec
.size(), 3);
121 equals(vec
[0], "baz");
122 equals(vec
[1], "bob");
123 equals(vec
[2], "dob");
124 vec
= Cnf
.FindVector("Test::Vector", "foo,bar");
125 equals(vec
.size(), 3);
126 equals(vec
[0], "baz");
127 equals(vec
[1], "bob");
128 equals(vec
[2], "dob");
129 Cnf
.Set("Test::Vector", "abel,bravo");
130 vec
= Cnf
.FindVector("Test::Vector", "foo,bar");
131 equals(vec
.size(), 2);
132 equals(vec
[0], "abel");
133 equals(vec
[1], "bravo");
135 //FIXME: Test for configuration file parsing;
136 // currently only integration/ tests test them implicitly