]> git.saurik.com Git - apt.git/blob - test/libapt/parsedepends_test.cc
warning: no previous declaration for foobar() [-Wmissing-declarations]
[apt.git] / test / libapt / parsedepends_test.cc
1 #include <apt-pkg/deblistparser.h>
2 #include <apt-pkg/configuration.h>
3
4 #include "assert.h"
5
6 int main(int argc,char *argv[]) {
7 std::string Package;
8 std::string Version;
9 unsigned int Op = 5;
10 unsigned int Null = 0;
11 bool StripMultiArch = true;
12 bool ParseArchFlags = false;
13 bool ParseRestrictionsList = false;
14 _config->Set("APT::Architecture","amd64");
15 _config->Set("APT::Build-Profiles","stage1");
16
17 const char* Depends =
18 "debhelper:any (>= 5.0), "
19 "libdb-dev:any, "
20 "gettext:native (<= 0.12), "
21 "libcurl4-gnutls-dev:native | libcurl3-gnutls-dev (>> 7.15.5), "
22 "debiandoc-sgml, "
23 "apt (>= 0.7.25), "
24 "not-for-me [ !amd64 ], "
25 "only-for-me [ amd64 ], "
26 "any-for-me [ any ], "
27 "not-for-darwin [ !darwin-any ], "
28 "cpu-for-me [ any-amd64 ], "
29 "os-for-me [ linux-any ], "
30 "cpu-not-for-me [ any-armel ], "
31 "os-not-for-me [ kfreebsd-any ], "
32 "not-in-stage1 <!profile.stage1>, "
33 "not-in-stage1-or-nodoc <!profile.nodoc !profile.stage1>, "
34 "only-in-stage1 <unknown.unknown profile.stage1>, "
35 "overlord-dev:any (= 7.15.3~) | overlord-dev:native (>> 7.15.5), "
36 ;
37
38 unsigned short runner = 0;
39 test:
40 // std::clog << (StripMultiArch ? "NO-Multi" : "Multi") << " " << (ParseArchFlags ? "Flags" : "NO-Flags") << std::endl;
41
42 // Stripping MultiArch is currently the default setting to not confuse
43 // non-MultiArch capable users of the library with "strange" extensions.
44 const char* Start = Depends;
45 const char* End = Depends + strlen(Depends);
46
47 Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
48 if (StripMultiArch == true)
49 equals("debhelper", Package);
50 else
51 equals("debhelper:any", Package);
52 equals("5.0", Version);
53 equals(Null | pkgCache::Dep::GreaterEq, Op);
54
55 Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
56 if (StripMultiArch == true)
57 equals("libdb-dev", Package);
58 else
59 equals("libdb-dev:any", Package);
60 equals("", Version);
61 equals(Null | pkgCache::Dep::NoOp, Op);
62
63 Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
64 if (StripMultiArch == true)
65 equals("gettext", Package);
66 else
67 equals("gettext:native", Package);
68 equals("0.12", Version);
69 equals(Null | pkgCache::Dep::LessEq, Op);
70
71 Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
72 if (StripMultiArch == true)
73 equals("libcurl4-gnutls-dev", Package);
74 else
75 equals("libcurl4-gnutls-dev:native", Package);
76 equals("", Version);
77 equals(Null | pkgCache::Dep::Or, Op);
78
79 Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
80 equals("libcurl3-gnutls-dev", Package);
81 equals("7.15.5", Version);
82 equals(Null | pkgCache::Dep::Greater, Op);
83
84 Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
85 equals("debiandoc-sgml", Package);
86 equals("", Version);
87 equals(Null | pkgCache::Dep::NoOp, Op);
88
89 Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
90 equals("apt", Package);
91 equals("0.7.25", Version);
92 equals(Null | pkgCache::Dep::GreaterEq, Op);
93
94 if (ParseArchFlags == true) {
95 Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
96 equals("", Package); // not-for-me
97 } else {
98 equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList));
99 Start = strstr(Start, ",");
100 Start++;
101 }
102
103 if (ParseArchFlags == true) {
104 Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
105 equals("only-for-me", Package);
106 equals("", Version);
107 equals(Null | pkgCache::Dep::NoOp, Op);
108 } else {
109 equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList));
110 Start = strstr(Start, ",");
111 Start++;
112 }
113
114 if (ParseArchFlags == true) {
115 Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
116 equals("any-for-me", Package);
117 equals("", Version);
118 equals(Null | pkgCache::Dep::NoOp, Op);
119 } else {
120 equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList));
121 Start = strstr(Start, ",");
122 Start++;
123 }
124
125 if (ParseArchFlags == true) {
126 Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
127 equals("not-for-darwin", Package);
128 equals("", Version);
129 equals(Null | pkgCache::Dep::NoOp, Op);
130 } else {
131 equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList));
132 Start = strstr(Start, ",");
133 Start++;
134 }
135
136 if (ParseArchFlags == true) {
137 Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
138 equals("cpu-for-me", Package);
139 equals("", Version);
140 equals(Null | pkgCache::Dep::NoOp, Op);
141 } else {
142 equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList));
143 Start = strstr(Start, ",");
144 Start++;
145 }
146
147 if (ParseArchFlags == true) {
148 Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
149 equals("os-for-me", Package);
150 equals("", Version);
151 equals(Null | pkgCache::Dep::NoOp, Op);
152 } else {
153 equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList));
154 Start = strstr(Start, ",");
155 Start++;
156 }
157
158 if (ParseArchFlags == true) {
159 Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
160 equals("", Package); // cpu-not-for-me
161 } else {
162 equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList));
163 Start = strstr(Start, ",");
164 Start++;
165 }
166
167 if (ParseArchFlags == true) {
168 Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
169 equals("", Package); // os-not-for-me
170 } else {
171 equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList));
172 Start = strstr(Start, ",");
173 Start++;
174 }
175
176 if (ParseRestrictionsList == true) {
177 Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
178 equals("", Package); // not-in-stage1
179 } else {
180 equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList));
181 Start = strstr(Start, ",");
182 Start++;
183 }
184
185 if (ParseRestrictionsList == true) {
186 Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
187 equals("", Package); // not-in-stage1-or-in-nodoc
188 } else {
189 equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList));
190 Start = strstr(Start, ",");
191 Start++;
192 }
193
194 if (ParseRestrictionsList == true) {
195 Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
196 equals("only-in-stage1", Package);
197 } else {
198 equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList));
199 Start = strstr(Start, ",");
200 Start++;
201 }
202
203 Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
204 if (StripMultiArch == true)
205 equals("overlord-dev", Package);
206 else
207 equals("overlord-dev:any", Package);
208 equals("7.15.3~", Version);
209 equals(Null | pkgCache::Dep::Equals | pkgCache::Dep::Or, Op);
210
211 debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
212 if (StripMultiArch == true)
213 equals("overlord-dev", Package);
214 else
215 equals("overlord-dev:native", Package);
216 equals("7.15.5", Version);
217 equals(Null | pkgCache::Dep::Greater, Op);
218
219 if (StripMultiArch == false)
220 if (ParseArchFlags == false)
221 ParseRestrictionsList = !ParseRestrictionsList;
222 ParseArchFlags = !ParseArchFlags;
223 StripMultiArch = !StripMultiArch;
224
225 runner++;
226 if (runner < 8)
227 goto test; // this is the prove: tests are really evil ;)
228
229 return 0;
230 }