30 #include <tagcoll/coll/simple.h>
31 #include <tagcoll/stream/sink.h>
32 #include <tagcoll/patch.h>
34 #include <wibble/operators.h>
39 #ifndef EPT_DEBTAGS_TESTH
40 #define EPT_DEBTAGS_TESTH
42 using namespace tagcoll;
45 using namespace ept::debtags;
46 using namespace wibble::operators;
55 for (Debtags::const_iterator i = debtags.begin(); i != debtags.end(); ++i)
61 int items = 0, tags = 0;
62 debtags.outputSystem(stream::countingSink(items, tags));
64 int pitems = 0, ptags = 0;
65 debtags.outputPatched(stream::countingSink(pitems, ptags));
69 assert(items <= pitems);
70 assert(tags <= ptags);
76 std::set<std::string> tags = debtags.getTagsOfItem(p);
77 assert( !tags.empty() );
80 for ( std::set< Tag >::iterator i = tags.begin(); i != tags.end(); ++ i ) {
81 std::cerr << i->id() <<
": " << i->fullname() << std::endl;
83 std::cerr <<
"---" << std::endl;
84 Tag t = voc().tagByName(
"interface::commandline" );
85 std::cerr << t.id() <<
": " << t.fullname() << std::endl;
88 assert_eq( tags.size(), 8u );
89 assert( tags.find(
"devel::buildtools") != tags.end() );
90 assert( tags.find(
"implemented-in::c++") != tags.end() );
91 assert( tags.find(
"interface::commandline") != tags.end() );
92 assert( tags.find(
"role::program") != tags.end() );
93 assert( tags.find(
"scope::application") != tags.end() );
94 assert( tags.find(
"suite::debian") != tags.end() );
95 assert( tags.find(
"use::searching") != tags.end() );
96 assert( tags.find(
"works-with::software:package") != tags.end() );
107 std::set<std::string> tags = debtags.getTagsOfItem(p);
108 assert(!tags.empty());
151 std::set<string> packages = debtags.getItemsHavingTags(tags);
153 assert(!packages.empty());
161 assert( p <= packages );
164 std::string tag = *tags.begin();
171 std::set<std::string> ts;
173 packages = debtags.getItemsHavingTags(ts);
176 assert(!packages.empty());
178 assert( p <= packages );
185 std::string patchfile = Path::debtagsUserSourceDir() +
"patch";
186 unlink(patchfile.c_str());
191 std::set<std::string> tags = debtags.getTagsOfItem(p);
192 assert(!tags.empty());
195 std::string t =
"use::gameplaying";
196 assert(tags.find(t) == tags.end());
199 PatchList<string, string> change;
200 change.addPatch(Patch<string, string>(p, wibble::singleton(t), wibble::Empty<string>()));
201 debtags.applyChange(change);
204 PatchList<string, string> tmp = debtags.changes();
205 assert(tmp.size() > 0);
206 assert_eq(tmp.size(), 1u);
209 tags = debtags.getTagsOfItem(p);
210 assert(!tags.empty());
212 t =
"use::gameplaying";
213 assert(tags.find(t) != tags.end());
219 FILE* in = fopen(patchfile.c_str(),
"r");
222 while ((c = getc(in)) != EOF)
226 assert_eq(writtenPatch,
string(
"debtags: +use::gameplaying\n"));
228 unlink(patchfile.c_str());
231 debtags.applyChange(change);
234 tmp = debtags.changes();
235 assert_eq(tmp.size(), 1u);
236 assert_eq(tmp.begin()->first, p);
237 assert_eq(tmp.begin()->second.item, p);
249 assert(empty.begin() == empty.end());
253 tagcoll::PatchList<std::string, std::string> patches = empty.
changes();
254 assert(patches.empty());
256 set<std::string> res = empty.getTagsOfItem(
"apt");
262 res = empty.getAllTags();
265 tagcoll::coll::Simple<string, std::string> coll;
267 assert_eq(coll.itemCount(), 0u);
272 assert_eq(coll.itemCount(), 0u);
277 #include <ept/debtags/debtags.tcc>
278 #include <tagcoll/coll/simple.tcc>