]>
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 "overlord-dev:any (= 7.15.3~) | overlord-dev:native (>> 7.15.5), "
27 unsigned short runner
= 0;
29 // std::clog << (StripMultiArch ? "NO-Multi" : "Multi") << " " << (ParseArchFlags ? "Flags" : "NO-Flags") << std::endl;
31 // Stripping MultiArch is currently the default setting to not confuse
32 // non-MultiArch capable users of the library with "strange" extensions.
33 const char* Start
= Depends
;
34 const char* End
= Depends
+ strlen(Depends
);
36 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
);
37 if (StripMultiArch
== true)
38 equals("debhelper", Package
);
40 equals("debhelper:any", Package
);
41 equals("5.0", Version
);
42 equals(Null
| pkgCache::Dep::GreaterEq
, Op
);
44 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
);
45 if (StripMultiArch
== true)
46 equals("libdb-dev", Package
);
48 equals("libdb-dev:any", Package
);
50 equals(Null
| pkgCache::Dep::NoOp
, Op
);
52 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
);
53 if (StripMultiArch
== true)
54 equals("gettext", Package
);
56 equals("gettext:native", Package
);
57 equals("0.12", Version
);
58 equals(Null
| pkgCache::Dep::LessEq
, Op
);
60 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
);
61 if (StripMultiArch
== true)
62 equals("libcurl4-gnutls-dev", Package
);
64 equals("libcurl4-gnutls-dev:native", Package
);
66 equals(Null
| pkgCache::Dep::Or
, Op
);
68 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
);
69 equals("libcurl3-gnutls-dev", Package
);
70 equals("7.15.5", Version
);
71 equals(Null
| pkgCache::Dep::Greater
, Op
);
73 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
);
74 equals("debiandoc-sgml", Package
);
76 equals(Null
| pkgCache::Dep::NoOp
, Op
);
78 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
);
79 equals("apt", Package
);
80 equals("0.7.25", Version
);
81 equals(Null
| pkgCache::Dep::GreaterEq
, Op
);
83 if (ParseArchFlags
== true) {
84 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
);
85 equals("", Package
); // not-for-me
87 equals(true, 0 == debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
));
88 Start
= strstr(Start
, ",");
92 if (ParseArchFlags
== true) {
93 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
);
94 equals("only-for-me", Package
);
96 equals(Null
| pkgCache::Dep::NoOp
, Op
);
98 equals(true, 0 == debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
));
99 Start
= strstr(Start
, ",");
103 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
);
104 if (StripMultiArch
== true)
105 equals("overlord-dev", Package
);
107 equals("overlord-dev:any", Package
);
108 equals("7.15.3~", Version
);
109 equals(Null
| pkgCache::Dep::Equals
| pkgCache::Dep::Or
, Op
);
111 Start
= debListParser::ParseDepends(Start
, End
, Package
, Version
, Op
, ParseArchFlags
, StripMultiArch
);
112 if (StripMultiArch
== true)
113 equals("overlord-dev", Package
);
115 equals("overlord-dev:native", Package
);
116 equals("7.15.5", Version
);
117 equals(Null
| pkgCache::Dep::Greater
, Op
);
119 if (StripMultiArch
== false)
120 ParseArchFlags
= true;
121 StripMultiArch
= !StripMultiArch
;
125 goto test
; // this is the prove: tests are really evil ;)