]>
Commit | Line | Data |
---|---|---|
41c81fd8 DK |
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[]) { | |
8f3ba4e8 DK |
7 | std::string Package; |
8 | std::string Version; | |
41c81fd8 DK |
9 | unsigned int Op = 5; |
10 | unsigned int Null = 0; | |
11 | bool StripMultiArch = true; | |
12 | bool ParseArchFlags = false; | |
13 | _config->Set("APT::Architecture","dsk"); | |
14 | ||
15 | const char* Depends = | |
16 | "debhelper:any (>= 5.0), " | |
17 | "libdb-dev:any, " | |
18 | "gettext:native (<= 0.12), " | |
19 | "libcurl4-gnutls-dev:native | libcurl3-gnutls-dev (>> 7.15.5), " | |
20 | "debiandoc-sgml, " | |
21 | "apt (>= 0.7.25), " | |
22 | "not-for-me [ !dsk ], " | |
23 | "only-for-me [ dsk ], " | |
af5cf929 DK |
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 ], " | |
41c81fd8 DK |
30 | "overlord-dev:any (= 7.15.3~) | overlord-dev:native (>> 7.15.5), " |
31 | ; | |
32 | ||
33 | unsigned short runner = 0; | |
34 | test: | |
35 | // std::clog << (StripMultiArch ? "NO-Multi" : "Multi") << " " << (ParseArchFlags ? "Flags" : "NO-Flags") << std::endl; | |
36 | ||
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); | |
41 | ||
42 | Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); | |
43 | if (StripMultiArch == true) | |
44 | equals("debhelper", Package); | |
45 | else | |
46 | equals("debhelper:any", Package); | |
47 | equals("5.0", Version); | |
48 | equals(Null | pkgCache::Dep::GreaterEq, Op); | |
49 | ||
50 | Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); | |
51 | if (StripMultiArch == true) | |
52 | equals("libdb-dev", Package); | |
53 | else | |
54 | equals("libdb-dev:any", Package); | |
55 | equals("", Version); | |
56 | equals(Null | pkgCache::Dep::NoOp, Op); | |
57 | ||
58 | Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); | |
59 | if (StripMultiArch == true) | |
60 | equals("gettext", Package); | |
61 | else | |
62 | equals("gettext:native", Package); | |
63 | equals("0.12", Version); | |
64 | equals(Null | pkgCache::Dep::LessEq, Op); | |
65 | ||
66 | Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); | |
67 | if (StripMultiArch == true) | |
68 | equals("libcurl4-gnutls-dev", Package); | |
69 | else | |
70 | equals("libcurl4-gnutls-dev:native", Package); | |
71 | equals("", Version); | |
72 | equals(Null | pkgCache::Dep::Or, Op); | |
73 | ||
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); | |
78 | ||
79 | Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); | |
80 | equals("debiandoc-sgml", Package); | |
81 | equals("", Version); | |
82 | equals(Null | pkgCache::Dep::NoOp, Op); | |
83 | ||
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); | |
88 | ||
89 | if (ParseArchFlags == true) { | |
90 | Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); | |
91 | equals("", Package); // not-for-me | |
92 | } else { | |
93 | equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch)); | |
94 | Start = strstr(Start, ","); | |
95 | Start++; | |
96 | } | |
97 | ||
98 | if (ParseArchFlags == true) { | |
99 | Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); | |
100 | equals("only-for-me", Package); | |
101 | equals("", Version); | |
102 | equals(Null | pkgCache::Dep::NoOp, Op); | |
103 | } else { | |
104 | equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch)); | |
105 | Start = strstr(Start, ","); | |
106 | Start++; | |
107 | } | |
108 | ||
af5cf929 DK |
109 | if (ParseArchFlags == true) { |
110 | Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); | |
111 | equals("any-for-me", Package); | |
112 | equals("", Version); | |
113 | equals(Null | pkgCache::Dep::NoOp, Op); | |
114 | } else { | |
115 | equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch)); | |
116 | Start = strstr(Start, ","); | |
117 | Start++; | |
118 | } | |
119 | ||
120 | if (ParseArchFlags == true) { | |
121 | Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); | |
122 | equals("not-for-darwin", Package); | |
123 | equals("", Version); | |
124 | equals(Null | pkgCache::Dep::NoOp, Op); | |
125 | } else { | |
126 | equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch)); | |
127 | Start = strstr(Start, ","); | |
128 | Start++; | |
129 | } | |
130 | ||
131 | if (ParseArchFlags == true) { | |
132 | Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); | |
133 | equals("cpu-for-me", Package); | |
134 | equals("", Version); | |
135 | equals(Null | pkgCache::Dep::NoOp, Op); | |
136 | } else { | |
137 | equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch)); | |
138 | Start = strstr(Start, ","); | |
139 | Start++; | |
140 | } | |
141 | ||
142 | if (ParseArchFlags == true) { | |
143 | Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); | |
144 | equals("os-for-me", Package); | |
145 | equals("", Version); | |
146 | equals(Null | pkgCache::Dep::NoOp, Op); | |
147 | } else { | |
148 | equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch)); | |
149 | Start = strstr(Start, ","); | |
150 | Start++; | |
151 | } | |
152 | ||
153 | if (ParseArchFlags == true) { | |
154 | Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); | |
155 | equals("", Package); // cpu-not-for-me | |
156 | } else { | |
157 | equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch)); | |
158 | Start = strstr(Start, ","); | |
159 | Start++; | |
160 | } | |
161 | ||
162 | if (ParseArchFlags == true) { | |
163 | Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); | |
164 | equals("", Package); // os-not-for-me | |
165 | } else { | |
166 | equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch)); | |
167 | Start = strstr(Start, ","); | |
168 | Start++; | |
169 | } | |
170 | ||
41c81fd8 DK |
171 | Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); |
172 | if (StripMultiArch == true) | |
173 | equals("overlord-dev", Package); | |
174 | else | |
175 | equals("overlord-dev:any", Package); | |
176 | equals("7.15.3~", Version); | |
177 | equals(Null | pkgCache::Dep::Equals | pkgCache::Dep::Or, Op); | |
178 | ||
179 | Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); | |
180 | if (StripMultiArch == true) | |
181 | equals("overlord-dev", Package); | |
182 | else | |
183 | equals("overlord-dev:native", Package); | |
184 | equals("7.15.5", Version); | |
185 | equals(Null | pkgCache::Dep::Greater, Op); | |
186 | ||
187 | if (StripMultiArch == false) | |
188 | ParseArchFlags = true; | |
189 | StripMultiArch = !StripMultiArch; | |
190 | ||
191 | runner++; | |
192 | if (runner < 4) | |
193 | goto test; // this is the prove: tests are really evil ;) | |
194 | ||
195 | return 0; | |
196 | } |