]>
git.saurik.com Git - apt.git/blob - test/libapt/parsedepends_test.cc
1 #include <apt-pkg/deblistparser.h>
2 #include <apt-pkg/configuration.h>
6 int main(int argc
,char *argv
[]) {
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");
18 "debhelper:any (>= 5.0), "
20 "gettext:native (<= 0.12), "
21 "libcurl4-gnutls-dev:native | libcurl3-gnutls-dev (>> 7.15.5), "
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), "
38 unsigned short runner
= 0;
40 // std::clog << (StripMultiArch ? "NO-Multi" : "Multi") << " " << (ParseArchFlags ? "Flags" : "NO-Flags") << std::endl;
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
);
47 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
48 if (StripMultiArch
== true)
49 equals("debhelper", Package
);
51 equals("debhelper:any", Package
);
52 equals("5.0", Version
);
53 equals(Null
| pkgCache::Dep::GreaterEq
, Op
);
55 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
56 if (StripMultiArch
== true)
57 equals("libdb-dev", Package
);
59 equals("libdb-dev:any", Package
);
61 equals(Null
| pkgCache::Dep::NoOp
, Op
);
63 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
64 if (StripMultiArch
== true)
65 equals("gettext", Package
);
67 equals("gettext:native", Package
);
68 equals("0.12", Version
);
69 equals(Null
| pkgCache::Dep::LessEq
, Op
);
71 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
72 if (StripMultiArch
== true)
73 equals("libcurl4-gnutls-dev", Package
);
75 equals("libcurl4-gnutls-dev:native", Package
);
77 equals(Null
| pkgCache::Dep::Or
, Op
);
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
);
84 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
85 equals("debiandoc-sgml", Package
);
87 equals(Null
| pkgCache::Dep::NoOp
, Op
);
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
);
94 if (ParseArchFlags
== true) {
95 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
96 equals("", Package
); // not-for-me
98 equals(true, 0 == debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
));
99 Start
= strstr(Start
, ",");
103 if (ParseArchFlags
== true) {
104 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
105 equals("only-for-me", Package
);
107 equals(Null
| pkgCache::Dep::NoOp
, Op
);
109 equals(true, 0 == debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
));
110 Start
= strstr(Start
, ",");
114 if (ParseArchFlags
== true) {
115 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
116 equals("any-for-me", Package
);
118 equals(Null
| pkgCache::Dep::NoOp
, Op
);
120 equals(true, 0 == debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
));
121 Start
= strstr(Start
, ",");
125 if (ParseArchFlags
== true) {
126 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
127 equals("not-for-darwin", Package
);
129 equals(Null
| pkgCache::Dep::NoOp
, Op
);
131 equals(true, 0 == debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
));
132 Start
= strstr(Start
, ",");
136 if (ParseArchFlags
== true) {
137 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
138 equals("cpu-for-me", Package
);
140 equals(Null
| pkgCache::Dep::NoOp
, Op
);
142 equals(true, 0 == debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
));
143 Start
= strstr(Start
, ",");
147 if (ParseArchFlags
== true) {
148 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
149 equals("os-for-me", Package
);
151 equals(Null
| pkgCache::Dep::NoOp
, Op
);
153 equals(true, 0 == debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
));
154 Start
= strstr(Start
, ",");
158 if (ParseArchFlags
== true) {
159 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
160 equals("", Package
); // cpu-not-for-me
162 equals(true, 0 == debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
));
163 Start
= strstr(Start
, ",");
167 if (ParseArchFlags
== true) {
168 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
169 equals("", Package
); // os-not-for-me
171 equals(true, 0 == debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
));
172 Start
= strstr(Start
, ",");
176 if (ParseRestrictionsList
== true) {
177 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
178 equals("", Package
); // not-in-stage1
180 equals(true, 0 == debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
));
181 Start
= strstr(Start
, ",");
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
189 equals(true, 0 == debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
));
190 Start
= strstr(Start
, ",");
194 if (ParseRestrictionsList
== true) {
195 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
196 equals("only-in-stage1", Package
);
198 equals(true, 0 == debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
));
199 Start
= strstr(Start
, ",");
203 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
204 if (StripMultiArch
== true)
205 equals("overlord-dev", Package
);
207 equals("overlord-dev:any", Package
);
208 equals("7.15.3~", Version
);
209 equals(Null
| pkgCache::Dep::Equals
| pkgCache::Dep::Or
, Op
);
211 debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
, ParseRestrictionsList
);
212 if (StripMultiArch
== true)
213 equals("overlord-dev", Package
);
215 equals("overlord-dev:native", Package
);
216 equals("7.15.5", Version
);
217 equals(Null
| pkgCache::Dep::Greater
, Op
);
219 if (StripMultiArch
== false)
220 if (ParseArchFlags
== false)
221 ParseRestrictionsList
= !ParseRestrictionsList
;
222 ParseArchFlags
= !ParseArchFlags
;
223 StripMultiArch
= !StripMultiArch
;
227 goto test
; // this is the prove: tests are really evil ;)