diff options
author | Enrico Zini <enrico@enricozini.org> | 2015-09-10 11:23:57 +0200 |
---|---|---|
committer | Enrico Zini <enrico@enricozini.org> | 2015-09-10 11:23:57 +0200 |
commit | c4dce3d9e4331b9f2fdbef5517a054ebf20c7d3d (patch) | |
tree | 5521e7e7aa8c10baf406520ca4953019fa57aa80 /ept/debtags | |
parent | fb21a4dfe2c81640379f64855509fb7613530887 (diff) | |
download | libept-c4dce3d9e4331b9f2fdbef5517a054ebf20c7d3d.tar.gz |
Use build-in test framework instead of wibble
Diffstat (limited to 'ept/debtags')
-rw-r--r-- | ept/debtags/debtags-test.cc | 167 | ||||
-rw-r--r-- | ept/debtags/debtags.test.h | 197 | ||||
-rw-r--r-- | ept/debtags/vocabulary-test.cc | 195 | ||||
-rw-r--r-- | ept/debtags/vocabulary.test.h | 222 |
4 files changed, 362 insertions, 419 deletions
diff --git a/ept/debtags/debtags-test.cc b/ept/debtags/debtags-test.cc new file mode 100644 index 0000000..3a8fca5 --- /dev/null +++ b/ept/debtags/debtags-test.cc @@ -0,0 +1,167 @@ +#include "debtags.h" +#include <ept/test.h> +#include <wibble/operators.h> +#include <cstdio> + +using namespace tagcoll; +using namespace std; +using namespace ept; +using namespace ept::debtags; +using namespace ept::tests; +using namespace wibble::operators; + +#define testfile TEST_ENV_DIR "debtags/package-tags" + +namespace { + +class Tests : public TestCase +{ + using TestCase::TestCase; + + void register_tests() override + { + add_method("iterate", []() { + EnvOverride eo("DEBTAGS_TAGS", testfile); + Debtags debtags; + for (Debtags::const_iterator i = debtags.begin(); i != debtags.end(); ++i) + { + *i; + i->first; + i->second; + } + }); + + add_method("lookup_tags", []() { + EnvOverride eo("DEBTAGS_TAGS", testfile); + Debtags debtags; + string p("debtags"); + std::set<std::string> tags = debtags.getTagsOfItem(p); + wassert(actual(tags.empty()).isfalse()); + +#if 0 + for ( std::set< Tag >::iterator i = tags.begin(); i != tags.end(); ++ i ) { + std::cerr << i->id() << ": " << i->fullname() << std::endl; + } + std::cerr << "---" << std::endl; + Tag t = voc().tagByName( "interface::commandline" ); + std::cerr << t.id() << ": " << t.fullname() << std::endl; +#endif + + wassert(actual(tags.size()) == 8u); + wassert(actual(tags.find("devel::buildtools") != tags.end()).istrue()); + wassert(actual(tags.find("implemented-in::c++") != tags.end()).istrue()); + wassert(actual(tags.find("interface::commandline") != tags.end()).istrue()); + wassert(actual(tags.find("role::program") != tags.end()).istrue()); + wassert(actual(tags.find("scope::application") != tags.end()).istrue()); + wassert(actual(tags.find("suite::debian") != tags.end()).istrue()); + wassert(actual(tags.find("use::searching") != tags.end()).istrue()); + wassert(actual(tags.find("works-with::software:package") != tags.end()).istrue()); + }); + + add_method("lookup_packages", []() { + using namespace std; + EnvOverride eo("DEBTAGS_TAGS", testfile); + Debtags debtags; + + /* Get the 'debtags' package */ + string p("debtags"); + + /* Get its tags */ + std::set<std::string> tags = debtags.getTagsOfItem(p); + wassert(actual(tags.empty()).isfalse()); + + /* + cerr << "Intersection size: " << endl; + using namespace wibble::operators; + std::set<Tag>::const_iterator dbgi = tags.begin(); + cerr << "* " << dbgi->fullname() << ": " << dbgi->id() << endl; + std::set<int> dbgres = debtags.tagdb().getItemsHavingTag(dbgi->id()); + std::set<Package> dbgpres = debtags.getItemsHavingTag(*dbgi); + cerr << " #pkgs " << dbgres.size() << " == " << dbgpres.size() << endl; + cerr << " #isec " << dbgres.size() << " == " << dbgpres.size() << endl; + cerr << " "; ppset(dbgpres); cerr << endl; + cerr << " "; piset(dbgres); cerr << endl; + for (++dbgi ; dbgi != tags.end(); ++dbgi) + { + cerr << "* " << dbgi->fullname() << ": " << dbgi->id() << endl; + std::set<Package> dbgpkgs = debtags.getItemsHavingTag(*dbgi); + std::set<int> dbgids = debtags.tagdb().getItemsHavingTag(dbgi->id()); + cerr << " "; ppset(dbgpkgs); cerr << endl; + cerr << " "; piset(dbgids); cerr << endl; + cerr << " #pkgs " << dbgpkgs.size() << " == " << dbgids.size() << endl; + dbgres &= dbgids; + dbgpres &= dbgpkgs; + cerr << " #isec " << dbgres.size() << " == " << dbgpres.size() << endl; + } + cerr << " " << dbgres.size() << endl << "Results: " << endl; + for (std::set<int>::const_iterator i = dbgres.begin(); i != dbgres.end(); ++i) + cerr << " " << *i << endl; + */ + + + // cerr << "Tags of debtags: "; + // for (std::set<Tag>::const_iterator i = tags.begin(); i != tags.end(); ++i) + // { + // cerr << " " + i->fullname() << endl; + // std::set<Package> packages = debtags.getItemsHavingTag(*i); + // for (std::set<Package>::const_iterator p = packages.begin(); + // p != packages.end(); ++p) + // cerr << " PKG " << p->name() << endl; + // } + // cerr << endl; + + /* Get the items for the tagset of 'debtags' */ + std::set<string> packages = debtags.getItemsHavingTags(tags); + //cerr << packages.size() << endl; + wassert(actual(packages.empty()).isfalse()); + /* + for ( std::set< Package >::iterator i = packages.begin(); i != packages.end(); ++ i ) + std::cerr << i->name() << std::endl; + std::cerr << "---" << std::endl; + std::cerr << p.name() << std::endl; + */ + /* They should at least contain 'debtags' */ + wassert(actual(p <= packages).istrue()); + + /* Get one of the tags of 'debtags' */ + std::string tag = *tags.begin(); + + /* Get its items */ + { + /* Need this workaround until I figure out how to tell the new GCC + * that TagDB is a TDBReadonlyDiskIndex and should behave as such + */ + std::set<std::string> ts; + ts.insert(tag); + packages = debtags.getItemsHavingTags(ts); + } + //packages = c.debtags().tagdb().getItems(tag); + wassert(actual(packages.empty()).isfalse()); + /* They should at least contain 'debtags' */ + wassert(actual(p <= packages).istrue()); + + //c.debtags().getTags(""); // XXX HACK AWW! + }); + + add_method("empty", []() { + // If there is no data, Debtags should work as an empty collection + EnvOverride eo("DEBTAGS_TAGS", "./empty/notags"); + Debtags empty; + + wassert(actual(empty.begin() == empty.end()).istrue()); + wassert(actual(empty.timestamp()) == 0); + wassert(actual(empty.hasData()).isfalse()); + + set<std::string> res = empty.getTagsOfItem("apt"); + wassert(actual(res.empty()).istrue()); + // TODO: currently does not compile because of a bug in tagcoll + //res = empty.getTagsOfItems(wibble::singleton(string("apt"))); + //assert(res.empty()); + + res = empty.getAllTags(); + wassert(actual(res.empty()).istrue()); + }); + } +} tests("debtags"); + +} diff --git a/ept/debtags/debtags.test.h b/ept/debtags/debtags.test.h deleted file mode 100644 index 8376a9d..0000000 --- a/ept/debtags/debtags.test.h +++ /dev/null @@ -1,197 +0,0 @@ -// -*- mode: c++; tab-width: 4; indent-tabs-mode: t -*- -/** - * @file - * @author Enrico Zini (enrico) <enrico@enricozini.org> - */ - -/* - * Test for the Debtags data provider - * - * Copyright (C) 2003-2007 Enrico Zini <enrico@debian.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include <ept/debtags/debtags.h> -#include <wibble/operators.h> - -#include <ept/test.h> -#include <cstdio> - -#ifndef EPT_DEBTAGS_TESTH -#define EPT_DEBTAGS_TESTH - -using namespace tagcoll; -using namespace std; -using namespace ept; -using namespace ept::debtags; -using namespace wibble::operators; - -#define testfile TEST_ENV_DIR "debtags/package-tags" - -struct TestDebtags : DebtagsTestEnvironment -{ - TestDebtags() {} - - Test _1() - { - EnvOverride eo("DEBTAGS_TAGS", testfile); - Debtags debtags; - for (Debtags::const_iterator i = debtags.begin(); i != debtags.end(); ++i) - { - *i; - i->first; - i->second; - } - } - - Test _2() - { - EnvOverride eo("DEBTAGS_TAGS", testfile); - Debtags debtags; - string p("debtags"); - std::set<std::string> tags = debtags.getTagsOfItem(p); - assert( !tags.empty() ); - -#if 0 - for ( std::set< Tag >::iterator i = tags.begin(); i != tags.end(); ++ i ) { - std::cerr << i->id() << ": " << i->fullname() << std::endl; - } - std::cerr << "---" << std::endl; - Tag t = voc().tagByName( "interface::commandline" ); - std::cerr << t.id() << ": " << t.fullname() << std::endl; -#endif - - assert_eq( tags.size(), 8u ); - assert( tags.find("devel::buildtools") != tags.end() ); - assert( tags.find("implemented-in::c++") != tags.end() ); - assert( tags.find("interface::commandline") != tags.end() ); - assert( tags.find("role::program") != tags.end() ); - assert( tags.find("scope::application") != tags.end() ); - assert( tags.find("suite::debian") != tags.end() ); - assert( tags.find("use::searching") != tags.end() ); - assert( tags.find("works-with::software:package") != tags.end() ); -} - - Test _3() - { - using namespace std; - EnvOverride eo("DEBTAGS_TAGS", testfile); - Debtags debtags; - - /* Get the 'debtags' package */ - string p("debtags"); - - /* Get its tags */ - std::set<std::string> tags = debtags.getTagsOfItem(p); - assert(!tags.empty()); - - /* - cerr << "Intersection size: " << endl; - using namespace wibble::operators; - std::set<Tag>::const_iterator dbgi = tags.begin(); - cerr << "* " << dbgi->fullname() << ": " << dbgi->id() << endl; - std::set<int> dbgres = debtags.tagdb().getItemsHavingTag(dbgi->id()); - std::set<Package> dbgpres = debtags.getItemsHavingTag(*dbgi); - cerr << " #pkgs " << dbgres.size() << " == " << dbgpres.size() << endl; - cerr << " #isec " << dbgres.size() << " == " << dbgpres.size() << endl; - cerr << " "; ppset(dbgpres); cerr << endl; - cerr << " "; piset(dbgres); cerr << endl; - for (++dbgi ; dbgi != tags.end(); ++dbgi) - { - cerr << "* " << dbgi->fullname() << ": " << dbgi->id() << endl; - std::set<Package> dbgpkgs = debtags.getItemsHavingTag(*dbgi); - std::set<int> dbgids = debtags.tagdb().getItemsHavingTag(dbgi->id()); - cerr << " "; ppset(dbgpkgs); cerr << endl; - cerr << " "; piset(dbgids); cerr << endl; - cerr << " #pkgs " << dbgpkgs.size() << " == " << dbgids.size() << endl; - dbgres &= dbgids; - dbgpres &= dbgpkgs; - cerr << " #isec " << dbgres.size() << " == " << dbgpres.size() << endl; - } - cerr << " " << dbgres.size() << endl << "Results: " << endl; - for (std::set<int>::const_iterator i = dbgres.begin(); i != dbgres.end(); ++i) - cerr << " " << *i << endl; - */ - - -// cerr << "Tags of debtags: "; -// for (std::set<Tag>::const_iterator i = tags.begin(); i != tags.end(); ++i) -// { -// cerr << " " + i->fullname() << endl; -// std::set<Package> packages = debtags.getItemsHavingTag(*i); -// for (std::set<Package>::const_iterator p = packages.begin(); -// p != packages.end(); ++p) -// cerr << " PKG " << p->name() << endl; -// } -// cerr << endl; - - /* Get the items for the tagset of 'debtags' */ - std::set<string> packages = debtags.getItemsHavingTags(tags); - //cerr << packages.size() << endl; - assert(!packages.empty()); - /* - for ( std::set< Package >::iterator i = packages.begin(); i != packages.end(); ++ i ) - std::cerr << i->name() << std::endl; - std::cerr << "---" << std::endl; - std::cerr << p.name() << std::endl; - */ - /* They should at least contain 'debtags' */ - assert( p <= packages ); - - /* Get one of the tags of 'debtags' */ - std::string tag = *tags.begin(); - - /* Get its items */ - { - /* Need this workaround until I figure out how to tell the new GCC - * that TagDB is a TDBReadonlyDiskIndex and should behave as such - */ - std::set<std::string> ts; - ts.insert(tag); - packages = debtags.getItemsHavingTags(ts); - } - //packages = c.debtags().tagdb().getItems(tag); - assert(!packages.empty()); - /* They should at least contain 'debtags' */ - assert( p <= packages ); - - //c.debtags().getTags(""); // XXX HACK AWW! -} - - // If there is no data, Debtags should work as an empty collection - Test _4() - { - EnvOverride eo("DEBTAGS_TAGS", "./empty/notags"); - Debtags empty; - - assert(empty.begin() == empty.end()); - assert_eq(empty.timestamp(), 0); - assert(!empty.hasData()); - - set<std::string> res = empty.getTagsOfItem("apt"); - assert(res.empty()); - // TODO: currently does not compile because of a bug in tagcoll - //res = empty.getTagsOfItems(wibble::singleton(string("apt"))); - //assert(res.empty()); - - res = empty.getAllTags(); - assert(res.empty()); -} - -}; - -#endif diff --git a/ept/debtags/vocabulary-test.cc b/ept/debtags/vocabulary-test.cc new file mode 100644 index 0000000..51f46f9 --- /dev/null +++ b/ept/debtags/vocabulary-test.cc @@ -0,0 +1,195 @@ +#include "ept/test.h" +#include "vocabulary.h" +#include "coll/set.h" +#include "ept/test.h" + +using namespace std; +using namespace tagcoll::utils; +using namespace ept::debtags; +using namespace ept::tests; + +#define testfile "debtags/vocabulary" + +namespace { + +class Tests : public TestCase +{ + using TestCase::TestCase; + + void register_tests() override + { + add_method("load", []() { + EnvOverride eo("DEBTAGS_VOCABULARY", testfile); + Vocabulary tags; // this will throw if it failed to load + }); + + add_method("has_facet", []() { + EnvOverride eo("DEBTAGS_VOCABULARY", testfile); + Vocabulary tags; + assert_true( tags.hasFacet( "works-with" ) ); + assert_true( !tags.hasFacet( "blah" ) ); + }); + + add_method("has_tag", []() { + EnvOverride eo("DEBTAGS_VOCABULARY", testfile); + Vocabulary tags; + assert_true( tags.hasTag( "works-with::people" ) ); + assert_true( !tags.hasTag( "works-with::foobar" ) ); + }); + + add_method("tagdata", []() { + EnvOverride eo("DEBTAGS_VOCABULARY", testfile); + Vocabulary tags; + const voc::TagData *people = tags.tagData( "works-with::people" ), + *foobar = tags.tagData( "works-with::foobar" ), + *blahg = tags.tagData( "works-with::blahg" ), + *text = tags.tagData( "works-with::text" ), + *people2 = tags.tagData( "works-with::people" ); + assert_true( people != foobar ); + assert_true( people != text ); + assert_true( people != blahg ); + assert_true( foobar == blahg ); + assert_true( foobar == foobar ); + assert_true( people == people2 ); + assert_true( people == people ); + }); + + add_method("tags", []() { + EnvOverride eo("DEBTAGS_VOCABULARY", testfile); + Vocabulary tags; + std::string a = "works-with::people", + b = "works-with::foobar"; + std::set<std::string> s = tags.tags(), + f = tags.tags( "works-with" ), + n = tags.tags( "nonsense" ); + assert_true( set_contains(s, a) ); + assert_true( set_contains(f, a) ); + assert_true( set_contains(s, f) ); + assert_true( !set_contains(s, b) ); + assert_true( !set_contains(f, b) ); + assert_true( n.empty() ); + }); + + add_method("facetdata", []() { + EnvOverride eo("DEBTAGS_VOCABULARY", testfile); + Vocabulary tags; + + const voc::FacetData* f = tags.facetData( "works-with" ); + assert_true(f); + wassert(actual(f->name) == "works-with"); + + const voc::TagData* t = tags.tagData( "works-with::people" ); + assert_true(t); + wassert(actual(t->name) == "works-with::people"); + }); + + add_method("facettags", []() { + EnvOverride eo("DEBTAGS_VOCABULARY", testfile); + Vocabulary tags; + + const voc::FacetData* f = tags.facetData( "works-with" ); + std::set<std::string> x = tags.tags( "works-with" ); + assert_true( x == f->tags() ); + }); + + add_method("missing_facet", []() { + EnvOverride eo("DEBTAGS_VOCABULARY", testfile); + Vocabulary tags; + + const voc::FacetData* f = tags.facetData( "does-not-work-with" ); + assert_true(!f); + }); + + add_method("missing_facet1", []() { + EnvOverride eo("DEBTAGS_VOCABULARY", testfile); + Vocabulary tags; + + const voc::FacetData* f = tags.facetData( "legacy" ); + assert_true(f); + wassert(actual(f->shortDescription()) == ""); + wassert(actual(f->longDescription()) == ""); + //wassert(actual(f.shortDescription( "weehee" )) == "weehee"); + }); + + add_method("one_letter_tag", []() { + EnvOverride eo("DEBTAGS_VOCABULARY", testfile); + Vocabulary tags; + + // assert_true that one-character tag names are parsed correctly + assert_true( tags.hasTag( "implemented-in::c" ) ); + }); + + add_method("iterate_facets", []() { + EnvOverride eo("DEBTAGS_VOCABULARY", testfile); + Vocabulary tags; + + // assert_true that all facets are somehow working + std::set<std::string> facets = tags.facets(); + + for (std::set<std::string>::const_iterator i = facets.begin(); + i != facets.end(); i++) + { + const voc::FacetData* f = tags.facetData(*i); + assert_true(f); + } + }); + + add_method("iterate_tags", []() { + EnvOverride eo("DEBTAGS_VOCABULARY", testfile); + Vocabulary voc; + + // assert_true that all tags are somehow working + std::set<std::string> tags = voc.tags(); + for (std::set<std::string>::const_iterator i = tags.begin(); + i != tags.end(); i++) + { + const voc::TagData* t = voc.tagData(*i); + assert_true(t); + } + }); + + add_method("first_last", []() { + // Check for correctness of the first and last tag in the vocabulary + EnvOverride eo("DEBTAGS_VOCABULARY", testfile); + Vocabulary tags; + + const voc::TagData* first = tags.tagData("accessibility::TODO"); + assert_true(first); + wassert(actual(first->name) == string("accessibility::TODO")); + wassert(actual(first->shortDescription()) == string("Need an extra tag")); + + const voc::TagData* last = tags.tagData("x11::xserver"); + assert_true(last); + wassert(actual(last->name) == string("x11::xserver")); + wassert(actual(last->shortDescription()) == string("X Server")); + }); + + add_method("get_all_tags", []() { + EnvOverride eo("DEBTAGS_VOCABULARY", testfile); + Vocabulary tags; + + // check that we're seeing all the tags for a facet + std::set<std::string> t = tags.tags("accessibility"); + wassert(actual(t.size()) == 10u); + + t = tags.tags("works-with-format"); + wassert(actual(t.size()) == 33u); + }); + + add_method("empty", []() { + // If there is no data, Vocabulary should work as an empty vocabulary + EnvOverride eo("DEBTAGS_VOCABULARY", "./empty/novocabularyhere"); + Vocabulary empty; + + assert_true(!empty.hasData()); + + set<std::string> facets = empty.facets(); + wassert(actual(facets.size()) == 0u); + + set<std::string> tags = empty.tags(); + wassert(actual(tags.size()) == 0u); + }); + } +} tests("debtags_vocabulary"); + +} diff --git a/ept/debtags/vocabulary.test.h b/ept/debtags/vocabulary.test.h deleted file mode 100644 index 4d698ea..0000000 --- a/ept/debtags/vocabulary.test.h +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Tag vocabulary access - * - * Copyright (C) 2003--2007 Enrico Zini <enrico@debian.org> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <wibble/test.h> -#include <ept/debtags/vocabulary.h> -#include <ept/debtags/coll/set.h> -#include "ept/test.h" - -using namespace std; -using namespace tagcoll::utils; -using namespace ept::debtags; - -#define testfile TEST_ENV_DIR "debtags/vocabulary" - - -struct TestVocabulary : DebtagsTestEnvironment -{ - Test _1() -{ - EnvOverride eo("DEBTAGS_VOCABULARY", testfile); - Vocabulary tags; // this will throw if it failed to load -} - - Test _2() -{ - EnvOverride eo("DEBTAGS_VOCABULARY", testfile); - Vocabulary tags; - assert( tags.hasFacet( "works-with" ) ); - assert( !tags.hasFacet( "blah" ) ); -} - - Test _3() -{ - EnvOverride eo("DEBTAGS_VOCABULARY", testfile); - Vocabulary tags; - assert( tags.hasTag( "works-with::people" ) ); - assert( !tags.hasTag( "works-with::foobar" ) ); -} - - Test _4() -{ - EnvOverride eo("DEBTAGS_VOCABULARY", testfile); - Vocabulary tags; - const voc::TagData *people = tags.tagData( "works-with::people" ), - *foobar = tags.tagData( "works-with::foobar" ), - *blahg = tags.tagData( "works-with::blahg" ), - *text = tags.tagData( "works-with::text" ), - *people2 = tags.tagData( "works-with::people" ); - assert( people != foobar ); - assert( people != text ); - assert( people != blahg ); - assert( foobar == blahg ); - assert( foobar == foobar ); - assert( people == people2 ); - assert( people == people ); -} - - Test _5() -{ - EnvOverride eo("DEBTAGS_VOCABULARY", testfile); - Vocabulary tags; - std::string a = "works-with::people", - b = "works-with::foobar"; - std::set<std::string> s = tags.tags(), - f = tags.tags( "works-with" ), - n = tags.tags( "nonsense" ); - assert( set_contains(s, a) ); - assert( set_contains(f, a) ); - assert( set_contains(s, f) ); - assert( !set_contains(s, b) ); - assert( !set_contains(f, b) ); - assert( n.empty() ); -} - - Test _6() -{ - EnvOverride eo("DEBTAGS_VOCABULARY", testfile); - Vocabulary tags; - - const voc::FacetData* f = tags.facetData( "works-with" ); - assert(f); - assert_eq(f->name, "works-with"); - - const voc::TagData* t = tags.tagData( "works-with::people" ); - assert(t); - assert_eq(t->name, "works-with::people"); -} - - Test _7() -{ - EnvOverride eo("DEBTAGS_VOCABULARY", testfile); - Vocabulary tags; - - const voc::FacetData* f = tags.facetData( "works-with" ); - std::set<std::string> x = tags.tags( "works-with" ); - assert( x == f->tags() ); -} - - Test _8() -{ - EnvOverride eo("DEBTAGS_VOCABULARY", testfile); - Vocabulary tags; - - const voc::FacetData* f = tags.facetData( "does-not-work-with" ); - assert(!f); -} - - Test _9() -{ - EnvOverride eo("DEBTAGS_VOCABULARY", testfile); - Vocabulary tags; - - const voc::FacetData* f = tags.facetData( "legacy" ); - assert(f); - assert_eq(f->shortDescription(), ""); - assert_eq(f->longDescription(), ""); - //assert_eq(f.shortDescription( "weehee" ), "weehee"); -} - - Test _10() -{ - EnvOverride eo("DEBTAGS_VOCABULARY", testfile); - Vocabulary tags; - - // assert that one-character tag names are parsed correctly - assert( tags.hasTag( "implemented-in::c" ) ); -} - - Test _11() -{ - EnvOverride eo("DEBTAGS_VOCABULARY", testfile); - Vocabulary tags; - - // assert that all facets are somehow working - std::set<std::string> facets = tags.facets(); - - for (std::set<std::string>::const_iterator i = facets.begin(); - i != facets.end(); i++) - { - const voc::FacetData* f = tags.facetData(*i); - assert(f); - } -} - - Test _12() -{ - EnvOverride eo("DEBTAGS_VOCABULARY", testfile); - Vocabulary voc; - - // assert that all tags are somehow working - std::set<std::string> tags = voc.tags(); - for (std::set<std::string>::const_iterator i = tags.begin(); - i != tags.end(); i++) - { - const voc::TagData* t = voc.tagData(*i); - assert(t); - } -} - -// Check for correctness of the first and last tag in the vocabulary - Test _13() -{ - EnvOverride eo("DEBTAGS_VOCABULARY", testfile); - Vocabulary tags; - - const voc::TagData* first = tags.tagData("accessibility::TODO"); - assert(first); - assert_eq(first->name, string("accessibility::TODO")); - assert_eq(first->shortDescription(), string("Need an extra tag")); - - const voc::TagData* last = tags.tagData("x11::xserver"); - assert(last); - assert_eq(last->name, string("x11::xserver")); - assert_eq(last->shortDescription(), string("X Server")); -} - - Test _14() -{ - EnvOverride eo("DEBTAGS_VOCABULARY", testfile); - Vocabulary tags; - - // check that we're seeing all the tags for a facet - std::set<std::string> t = tags.tags("accessibility"); - assert_eq(t.size(), 10u); - - t = tags.tags("works-with-format"); - assert_eq(t.size(), 33u); -} - -// If there is no data, Vocabulary should work as an empty vocabulary - Test _15() -{ - EnvOverride eo("DEBTAGS_VOCABULARY", "./empty/novocabularyhere"); - Vocabulary empty; - - assert(!empty.hasData()); - - set<std::string> facets = empty.facets(); - assert_eq(facets.size(), 0u); - - set<std::string> tags = empty.tags(); - assert_eq(tags.size(), 0u); -} - -}; |