diff --git a/libcorpus2/CMakeLists.txt b/libcorpus2/CMakeLists.txt index 551cf96e85873e41de170b1312964451c49063fa..bd66f8d2db9aceeaa24a1118be805d3cb459ef28 100644 --- a/libcorpus2/CMakeLists.txt +++ b/libcorpus2/CMakeLists.txt @@ -3,7 +3,7 @@ PROJECT(corpus2) set(corpus2_ver_major "1") set(corpus2_ver_minor "0") -set(corpus2_ver_patch "0") +set(corpus2_ver_patch "1") if(NOT LIBCORPUS2_SRC_DATA_DIR) diff --git a/libcorpus2/tagset.cpp b/libcorpus2/tagset.cpp index 4cc688181442f235518949877119fb41f914ee31..8f3a4f62d088fbcbffc3c62614a24ea14a5b8efa 100644 --- a/libcorpus2/tagset.cpp +++ b/libcorpus2/tagset.cpp @@ -122,7 +122,10 @@ Tag Tagset::parse_symbol(const std::string& s) const return Tag(0, m); } m = get_value_mask(s); - return Tag(0, m); + if (m.any()) { + return Tag(0, m); + } + throw TagParseError("Not a tagset symbol", s, "", id_string()); } void Tagset::parse_tag(const string_range &s, bool allow_extra, diff --git a/libcorpus2/tagset.h b/libcorpus2/tagset.h index b6e1c1afd1ec6fd1782f2684a6900135128e5570..f413d56837568ada2153ff44bf66c54898d2f7ee 100644 --- a/libcorpus2/tagset.h +++ b/libcorpus2/tagset.h @@ -129,7 +129,7 @@ public: * The resulting tags will usually be invalid as standalone tags, so * there is no validation performed. * - * An invalid string will result in a null tag being returned. + * An invalid string will result in a TagParseError exception. */ Tag parse_symbol(const std::string& s) const; diff --git a/tests/tag_split.cpp b/tests/tag_split.cpp index 098ef7a5e0c96bcd8ca79d613057d0c73558287c..f4749311f3e197ad67598b34e0df7c098aa5733e 100644 --- a/tests/tag_split.cpp +++ b/tests/tag_split.cpp @@ -242,6 +242,7 @@ BOOST_FIXTURE_TEST_CASE( symbols, F ) t = tagset->parse_symbol("C"); BOOST_CHECK_EQUAL(tagset->tag_to_symbol_string(t), "C"); BOOST_CHECK(tagset->tag_to_symbol_string(t, false) != "C"); + BOOST_CHECK_THROW(tagset->parse_symbol("asdf"), Corpus2::TagParseError); } BOOST_AUTO_TEST_SUITE_END()