From c1c501ca3559571c8292cd0f684274e09f07f9ff Mon Sep 17 00:00:00 2001 From: "florent.teppe" Date: Sun, 19 Sep 2021 15:05:48 +0200 Subject: [PATCH] Added test to make sure keyword search works even with non ascii characters --- .../mwdialogue/test_keywordsearch.cpp | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/apps/openmw_test_suite/mwdialogue/test_keywordsearch.cpp b/apps/openmw_test_suite/mwdialogue/test_keywordsearch.cpp index 431725be2c..25ea566165 100644 --- a/apps/openmw_test_suite/mwdialogue/test_keywordsearch.cpp +++ b/apps/openmw_test_suite/mwdialogue/test_keywordsearch.cpp @@ -65,3 +65,26 @@ TEST_F(KeywordSearchTest, keyword_test_conflict_resolution3) ASSERT_TRUE (matches.size() == 1); ASSERT_TRUE (std::string(matches.front().mBeg, matches.front().mEnd) == "bar lock"); } + + +TEST_F(KeywordSearchTest, keyword_test_utf8_word_begin) +{ + // We make sure that the search works well even if the character is not ASCII + MWDialogue::KeywordSearch search; + search.seed("états", 0); + search.seed("ïrradiés", 0); + search.seed("ça nous déçois", 0); + + + std::string text = "les nations unis ont réunis le monde entier, états units inclus pour parler du problème des gens ïrradiés et ça nous déçois"; + + std::vector::Match> matches; + search.highlightKeywords(text.begin(), text.end(), matches); + + ASSERT_TRUE (matches.size() == 3); + ASSERT_TRUE(std::string( matches[0].mBeg, matches[0].mEnd) == "états"); + ASSERT_TRUE(std::string( matches[1].mBeg, matches[1].mEnd) == "ïrradiés"); + ASSERT_TRUE(std::string( matches[2].mBeg, matches[2].mEnd) == "ça nous déçois"); + + //ASSERT_TRUE (std::string(matches.front().mBeg, matches.front().mEnd) == "bar lock"); +}