From d8840260e78f2bd8bae95af93f092dc9bdf7809a Mon Sep 17 00:00:00 2001 From: ilor <kailoran@gmail.com> Date: Wed, 27 Oct 2010 12:32:46 +0200 Subject: [PATCH] fix tests --- tests/tag_split.cpp | 22 ++++++++++++++-------- tests/tagset_parse.cpp | 8 ++++++-- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/tests/tag_split.cpp b/tests/tag_split.cpp index 997e0c2..1f4ca44 100644 --- a/tests/tag_split.cpp +++ b/tests/tag_split.cpp @@ -12,8 +12,9 @@ struct F { "A tag tog other a3 \n" "B data thing tag-thing thang\n" "C a b c \n" - "[POS]\n some A B [C]\n same A B\n"; - tagset.reset(new Corpus2::Tagset(tagset_string)); + "[POS]\n some A B [C]\n same A B \n P3 [A] [B]\n"; + tagset.reset(new Corpus2::Tagset()); + *tagset = Corpus2::Tagset::from_data(tagset_string); } boost::shared_ptr<Corpus2::Tagset> tagset; @@ -22,10 +23,15 @@ struct F { std::set<std::string> actual; std::vector<Corpus2::Tag> tags; Corpus2::Token t; - tagset->lexemes_into_token(t, UnicodeString(), s); + try { + tagset->lexemes_into_token(t, UnicodeString(), s); + } catch (Corpus2::TagParseError& e) { + throw; + } + foreach (const Corpus2::Lexeme& lex, t.lexemes()) { const Corpus2::Tag& tag = lex.tag(); - BOOST_WARN(tagset->validate_tag(tag, false)); + BOOST_WARN(tagset->validate_tag(tag, false, &std::cerr)); actual.insert(tagset->tag_to_string(tag)); tags.push_back(tag); } @@ -89,9 +95,9 @@ BOOST_FIXTURE_TEST_CASE( dots_plus, F ) BOOST_FIXTURE_TEST_CASE( missing, F ) { - const char tag[] = "some:data"; + const char tag[] = "P3:data"; std::set<std::string> r; - r.insert("some::data"); + r.insert("P3:data"); check_split(tag, r); } @@ -163,8 +169,8 @@ BOOST_FIXTURE_TEST_CASE( underscore_dots, F ) BOOST_FIXTURE_TEST_CASE( tag_size, F ) { Corpus2::Tag t = tagset->parse_simple_tag("some:tag:data", false); - Corpus2::Tag t2 = tagset->parse_simple_tag("some:tog", false); - Corpus2::Tag t3 = tagset->parse_simple_tag("same", false); + Corpus2::Tag t2 = tagset->parse_simple_tag("some:tog:data", false); + Corpus2::Tag t3 = tagset->parse_simple_tag("same:tag:data", false); BOOST_CHECK(tagset->tag_is_singular(t)); BOOST_CHECK_EQUAL(tagset->tag_size(t), 1); BOOST_CHECK(tagset->tag_is_singular(t2)); diff --git a/tests/tagset_parse.cpp b/tests/tagset_parse.cpp index 892e072..d5faa7d 100644 --- a/tests/tagset_parse.cpp +++ b/tests/tagset_parse.cpp @@ -26,19 +26,23 @@ BOOST_AUTO_TEST_CASE( empty ) BOOST_AUTO_TEST_CASE( minimal ) { + Corpus2::Tagset t; try { - parse(PRE POSA); + t = parse(PRE POSA); } catch (Corpus2::TagsetParseError& e) { BOOST_FAIL(e.info()); } + BOOST_CHECK_EQUAL(t.pos_count(), 1); } BOOST_AUTO_TEST_CASE( minimal_nonewline ) { + Corpus2::Tagset t; try { - parse(PRE "[POS]\n POS1"); + t = parse(PRE "[POS]\n POS1"); } catch (Corpus2::TagsetParseError& e) { BOOST_FAIL(e.info()); } + BOOST_CHECK_EQUAL(t.pos_count(), 1); } BOOST_AUTO_TEST_CASE( dupe_val ) -- GitLab