Go to the documentation of this file.00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <ept/debtags/maint/serializer.h>
00028 #include <ept/debtags/maint/pkgid.h>
00029 #include <ept/debtags/maint/path.h>
00030 #include <ept/debtags/vocabulary.h>
00031 #include <ept/debtags/debtags.h>
00032
00033 #include <tagcoll/coll/simple.h>
00034
00035 #include <wibble/singleton.h>
00036
00037 #include <ept/test.h>
00038
00039 using namespace std;
00040 using namespace tagcoll;
00041 using namespace ept;
00042 using namespace ept::debtags;
00043
00044 struct TestSerializer : DebtagsTestEnvironment
00045 {
00046 Debtags debtags;
00047 Vocabulary& voc;
00048 PkgId& pkgid;
00049
00050 TestSerializer()
00051 : voc(debtags.vocabulary()), pkgid(debtags.pkgid()) {}
00052
00053
00054
00055
00056
00057 Test _1()
00058 {
00059
00060 coll::Simple<string, string> source;
00061 source.insert(wibble::singleton(string("debtags")), wibble::singleton(string("use::editing")));
00062 source.insert(wibble::singleton(string("debtags")), wibble::singleton(string("role::program")));
00063
00064
00065 coll::Simple<int, int> dest;
00066 source.output(stringToInt(pkgid, voc, inserter(dest)));
00067
00068 assert_eq(dest.itemCount(), 1u);
00069 assert_eq(dest.tagCount(), 2u);
00070
00071
00072 coll::Simple<string, Tag> dest1;
00073 dest.output(intToPkg(pkgid, voc, inserter(dest1)));
00074
00075 assert_eq(dest1.itemCount(), 1u);
00076 assert_eq(dest1.tagCount(), 2u);
00077
00078 std::set<Tag> tags = dest1.getTagsOfItem("debtags");
00079 assert_eq(tags.size(), 2u);
00080
00081 Tag useEditing = voc.tagByName("use::editing");
00082 Tag roleProgram = voc.tagByName("role::program");
00083
00084 assert(tags.find(useEditing) != tags.end());
00085 assert(tags.find(roleProgram) != tags.end());
00086
00087
00088 coll::Simple<string, string> dest2;
00089 dest1.output(pkgToString(inserter(dest2)));
00090
00091 assert_eq(dest2.itemCount(), 1u);
00092 assert_eq(dest2.tagCount(), 2u);
00093
00094 std::set<std::string> tags1 = dest2.getTagsOfItem("debtags");
00095 assert_eq(tags1.size(), 2u);
00096
00097 assert(tags1.find("use::editing") != tags1.end());
00098 assert(tags1.find("role::program") != tags1.end());
00099 }
00100
00101
00102 Test _2()
00103 {
00104 PatchList<string, string> change;
00105 change.addPatch(Patch<string, string>("debtags",
00106 wibble::singleton(string("use::gameplaying")),
00107 wibble::singleton(string("use::editing"))));
00108
00109
00110 PatchList<int, int> intChange;
00111 change.output(patchStringToInt(pkgid, voc, tagcoll::inserter(intChange)));
00112 assert_eq(intChange.size(), 1u);
00113 assert_eq(intChange.begin()->second.added.size(), 1u);
00114 assert_eq(intChange.begin()->second.removed.size(), 1u);
00115
00116
00117 PatchList<string, string> change1;
00118 intChange.output(patchIntToString(pkgid, voc, tagcoll::inserter(change1)));
00119 assert_eq(change1.size(), 1u);
00120 assert_eq(change1.begin()->first, string("debtags"));
00121 assert_eq(change1.begin()->second.item, string("debtags"));
00122 assert_eq(change1.begin()->second.added.size(), 1u);
00123 assert_eq(*change1.begin()->second.added.begin(), string("use::gameplaying"));
00124 assert_eq(change1.begin()->second.removed.size(), 1u);
00125 assert_eq(*change1.begin()->second.removed.begin(), string("use::editing"));
00126 }
00127
00128 };
00129
00130 #include <tagcoll/coll/simple.tcc>
00131 #include <tagcoll/patch.tcc>
00132
00133