diff --git a/CMakeLists.txt b/CMakeLists.txt index 32e8a74..ef438af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.20) -project(OS2DSRules VERSION 0.0.4) +project(OS2DSRules VERSION 0.0.5) # Detect available compiler on the host system. set(gcc_like_cxx "$") diff --git a/lib/name_rule.cpp b/lib/name_rule.cpp index 71cb1e1..da65841 100644 --- a/lib/name_rule.cpp +++ b/lib/name_rule.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -34,9 +35,7 @@ MatchResult compose(const MatchResult &mr1, const MatchResult &mr2) noexcept { NameRule::find_matches(const std::string &content) const noexcept { MatchResults results; - static const auto is_end_of_word = [](char c) { - return c == '.' || c == ' ' || c == '\n' || c == '\0'; - }; + static constexpr auto is_end_of_word = make_predicate(' ', '.', '\n', '?', '-', '\t','\0'); bool in_word = false; auto word_begin = content.cbegin(); diff --git a/pyproject.toml b/pyproject.toml index e777ad4..8b1bf22 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "os2ds-rules" -version = "0.0.4" +version = "0.0.5" authors = [ { name="HackTheOxidation", email="tomas.hagenau@protonmail.ch" }, ] diff --git a/tests/testname.cpp b/tests/testname.cpp index 64dee55..a329f05 100644 --- a/tests/testname.cpp +++ b/tests/testname.cpp @@ -35,6 +35,16 @@ TEST_F(NameRuleTest, Test_Double_Name_Single_Match) { ASSERT_EQ(9, results[0].end()); } +TEST_F(NameRuleTest, Test_Double_Hyphenated_Name_Single_Match) { + NameRule rule; + auto results = rule.find_matches("John-Peter"); + + ASSERT_EQ(1, results.size()); + ASSERT_EQ(std::string("John Peter"), results[0].match()); + ASSERT_EQ(0, results[0].start()); + ASSERT_EQ(9, results[0].end()); +} + TEST_F(NameRuleTest, Test_Double_Name_Single_Name_Two_Matches) { NameRule rule; auto results = rule.find_matches("John Peter is usually just called John.");