Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <wibble/test.h>
00022 #include <ept/debtags/vocabulary.h>
00023 #include <ept/debtags/maint/path.h>
00024 #include <tagcoll/utils/set.h>
00025 #include <tagcoll/input/stdio.h>
00026
00027 #include "ept/test.h"
00028
00029 using namespace std;
00030 using namespace tagcoll::utils;
00031 using namespace ept::debtags;
00032
00033 struct TestVocabulary : DebtagsTestEnvironment
00034 {
00035 Vocabulary m_tags;
00036 Vocabulary& tags() { return m_tags; }
00037
00038 Test _1()
00039 {
00040 tags();
00041 }
00042
00043 Test _2()
00044 {
00045 assert( tags().hasFacet( "works-with" ) );
00046 assert( !tags().hasFacet( "blah" ) );
00047 }
00048
00049 Test _3()
00050 {
00051 assert( tags().hasTag( "works-with::people" ) );
00052 assert( !tags().hasTag( "works-with::midgets" ) );
00053 }
00054
00055 Test _4()
00056 {
00057 const voc::TagData *people = tags().tagData( "works-with::people" ),
00058 *midgets = tags().tagData( "works-with::midgets" ),
00059 *blahg = tags().tagData( "works-with::blahg" ),
00060 *text = tags().tagData( "works-with::text" ),
00061 *people2 = tags().tagData( "works-with::people" );
00062 assert( people != midgets );
00063 assert( people != text );
00064 assert( people != blahg );
00065 assert( midgets == blahg );
00066 assert( midgets == midgets );
00067 assert( people == people2 );
00068 assert( people == people );
00069 }
00070
00071 Test _5()
00072 {
00073 std::string a = "works-with::people",
00074 b = "works-with::midgets";
00075 std::set<std::string> s = tags().tags(),
00076 f = tags().tags( "works-with" ),
00077 n = tags().tags( "nonsense" );
00078 assert( set_contains(s, a) );
00079 assert( set_contains(f, a) );
00080 assert( set_contains(s, f) );
00081 assert( !set_contains(s, b) );
00082 assert( !set_contains(f, b) );
00083 assert( n.empty() );
00084 }
00085
00086 Test _6()
00087 {
00088 const voc::FacetData* f = tags().facetData( "works-with" );
00089 assert(f);
00090 assert_eq(f->name, "works-with");
00091
00092 const voc::TagData* t = tags().tagData( "works-with::people" );
00093 assert(t);
00094 assert_eq(t->name, "works-with::people");
00095 }
00096
00097 Test _7()
00098 {
00099 const voc::FacetData* f = tags().facetData( "works-with" );
00100 std::set<std::string> x = tags().tags( "works-with" );
00101 assert( x == f->tags() );
00102 }
00103
00104 Test _8()
00105 {
00106 const voc::FacetData* f = tags().facetData( "does-not-work-with" );
00107 assert(!f);
00108 }
00109
00110 Test _9()
00111 {
00112 const voc::FacetData* f = tags().facetData( "legacy" );
00113 assert(f);
00114 assert_eq(f->shortDescription(), "");
00115 assert_eq(f->longDescription(), "");
00116
00117 }
00118
00119 Test _10()
00120 {
00121
00122 assert( tags().hasTag( "implemented-in::c" ) );
00123 }
00124
00125 Test _11()
00126 {
00127
00128 std::set<std::string> facets = tags().facets();
00129
00130 for (std::set<std::string>::const_iterator i = facets.begin();
00131 i != facets.end(); i++)
00132 {
00133 const voc::FacetData* f = tags().facetData(*i);
00134 assert(f);
00135 }
00136 }
00137
00138 Test _12()
00139 {
00140
00141 std::set<std::string> tags = this->tags().tags();
00142 for (std::set<std::string>::const_iterator i = tags.begin();
00143 i != tags.end(); i++)
00144 {
00145 const voc::TagData* t = this->tags().tagData(*i);
00146 assert(t);
00147 }
00148 }
00149
00150
00151 Test _13()
00152 {
00153 Vocabulary& tags = this->tags();
00154
00155 const voc::TagData* first = tags.tagData("accessibility::TODO");
00156 assert(first);
00157 assert_eq(first->name, string("accessibility::TODO"));
00158 assert_eq(first->shortDescription(), string("Need an extra tag"));
00159
00160 const voc::TagData* last = tags.tagData("x11::xserver");
00161 assert(last);
00162 assert_eq(last->name, string("x11::xserver"));
00163 assert_eq(last->shortDescription(), string("X Server"));
00164 }
00165
00166 Test _14()
00167 {
00168
00169
00170 }
00171
00172 Test _15()
00173 {
00174
00175
00176 }
00177
00178 Test _16()
00179 {
00180
00181
00182 }
00183
00184 Test _17()
00185 {
00186
00187
00188 }
00189
00190 Test _18()
00191 {
00192
00193
00194 }
00195
00196 Test _19()
00197 {
00198
00199
00200 }
00201
00202 Test _20()
00203 {
00204
00205 std::set<std::string> t = tags().tags("accessibility");
00206 assert_eq(t.size(), 10u);
00207
00208 t = tags().tags("works-with-format");
00209 assert_eq(t.size(), 33u);
00210 }
00211
00212
00213 Test _21()
00214 {
00215 Path::OverrideDebtagsSourceDir odsd("./empty");
00216 Path::OverrideDebtagsIndexDir odid("./empty");
00217 Path::OverrideDebtagsUserSourceDir odusd("./empty");
00218 Path::OverrideDebtagsUserIndexDir oduid("./empty");
00219 Vocabulary empty;
00220
00221 assert(!empty.hasData());
00222
00223 set<std::string> facets = empty.facets();
00224 assert_eq(facets.size(), 0u);
00225
00226 set<std::string> tags = empty.tags();
00227 assert_eq(tags.size(), 0u);
00228 }
00229
00230 };
00231
00232