]>
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 _config
->Set("APT::Architecture","dsk");
16 "debhelper:any (>= 5.0), "
18 "gettext:native (<= 0.12), "
19 "libcurl4-gnutls-dev:native | libcurl3-gnutls-dev (>> 7.15.5), "
22 "not-for-me [ !dsk ], "
23 "only-for-me [ dsk ], "
24 "any-for-me [ any ], "
25 "not-for-darwin [ !darwin-any ], "
26 "cpu-for-me [ any-dsk ], "
27 "os-for-me [ linux-any ], "
28 "cpu-not-for-me [ any-amd64 ], "
29 "os-not-for-me [ kfreebsd-any ], "
30 "overlord-dev:any (= 7.15.3~) | overlord-dev:native (>> 7.15.5), "
33 unsigned short runner
= 0;
35 // std::clog << (StripMultiArch ? "NO-Multi" : "Multi") << " " << (ParseArchFlags ? "Flags" : "NO-Flags") << std::endl;
37 // Stripping MultiArch is currently the default setting to not confuse
38 // non-MultiArch capable users of the library with "strange" extensions.
39 const char* Start
= Depends
;
40 const char* End
= Depends
+ strlen(Depends
);
42 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
);
43 if (StripMultiArch
== true)
44 equals("debhelper", Package
);
46 equals("debhelper:any", Package
);
47 equals("5.0", Version
);
48 equals(Null
| pkgCache::Dep::GreaterEq
, Op
);
50 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
);
51 if (StripMultiArch
== true)
52 equals("libdb-dev", Package
);
54 equals("libdb-dev:any", Package
);
56 equals(Null
| pkgCache::Dep::NoOp
, Op
);
58 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
);
59 if (StripMultiArch
== true)
60 equals("gettext", Package
);
62 equals("gettext:native", Package
);
63 equals("0.12", Version
);
64 equals(Null
| pkgCache::Dep::LessEq
, Op
);
66 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
);
67 if (StripMultiArch
== true)
68 equals("libcurl4-gnutls-dev", Package
);
70 equals("libcurl4-gnutls-dev:native", Package
);
72 equals(Null
| pkgCache::Dep::Or
, Op
);
74 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
);
75 equals("libcurl3-gnutls-dev", Package
);
76 equals("7.15.5", Version
);
77 equals(Null
| pkgCache::Dep::Greater
, Op
);
79 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
);
80 equals("debiandoc-sgml", Package
);
82 equals(Null
| pkgCache::Dep::NoOp
, Op
);
84 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
);
85 equals("apt", Package
);
86 equals("0.7.25", Version
);
87 equals(Null
| pkgCache::Dep::GreaterEq
, Op
);
89 if (ParseArchFlags
== true) {
90 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
);
91 equals("", Package
); // not-for-me
93 equals(true, 0 == debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
));
94 Start
= strstr(Start
, ",");
98 if (ParseArchFlags
== true) {
99 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
);
100 equals("only-for-me", Package
);
102 equals(Null
| pkgCache::Dep::NoOp
, Op
);
104 equals(true, 0 == debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
));
105 Start
= strstr(Start
, ",");
109 if (ParseArchFlags
== true) {
110 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
);
111 equals("any-for-me", Package
);
113 equals(Null
| pkgCache::Dep::NoOp
, Op
);
115 equals(true, 0 == debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
));
116 Start
= strstr(Start
, ",");
120 if (ParseArchFlags
== true) {
121 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
);
122 equals("not-for-darwin", Package
);
124 equals(Null
| pkgCache::Dep::NoOp
, Op
);
126 equals(true, 0 == debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
));
127 Start
= strstr(Start
, ",");
131 if (ParseArchFlags
== true) {
132 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
);
133 equals("cpu-for-me", Package
);
135 equals(Null
| pkgCache::Dep::NoOp
, Op
);
137 equals(true, 0 == debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
));
138 Start
= strstr(Start
, ",");
142 if (ParseArchFlags
== true) {
143 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
);
144 equals("os-for-me", Package
);
146 equals(Null
| pkgCache::Dep::NoOp
, Op
);
148 equals(true, 0 == debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
));
149 Start
= strstr(Start
, ",");
153 if (ParseArchFlags
== true) {
154 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
);
155 equals("", Package
); // cpu-not-for-me
157 equals(true, 0 == debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
));
158 Start
= strstr(Start
, ",");
162 if (ParseArchFlags
== true) {
163 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
);
164 equals("", Package
); // os-not-for-me
166 equals(true, 0 == debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
));
167 Start
= strstr(Start
, ",");
171 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
);
172 if (StripMultiArch
== true)
173 equals("overlord-dev", Package
);
175 equals("overlord-dev:any", Package
);
176 equals("7.15.3~", Version
);
177 equals(Null
| pkgCache::Dep::Equals
| pkgCache::Dep::Or
, Op
);
179 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
);
180 if (StripMultiArch
== true)
181 equals("overlord-dev", Package
);
183 equals("overlord-dev:native", Package
);
184 equals("7.15.5", Version
);
185 equals(Null
| pkgCache::Dep::Greater
, Op
);
187 if (StripMultiArch
== false)
188 ParseArchFlags
= true;
189 StripMultiArch
= !StripMultiArch
;
193 goto test
; // this is the prove: tests are really evil ;)