diff --git a/test/server_search.cpp b/test/server_search.cpp index 11f9c0001..5aed75c8a 100644 --- a/test/server_search.cpp +++ b/test/server_search.cpp @@ -546,11 +546,27 @@ const std::vector LARGE_SEARCH_RESULTS = { // - Non-overlapping snippets can be joined with a " ... " in between. // +typedef std::vector Snippets; + std::string maskSnippetsInHtmlSearchResults(std::string s) { return replace(s, ".+", "SNIPPET TEXT WAS MASKED"); } +Snippets extractSearchResultSnippetsFromHtml(const std::string& html) +{ + Snippets snippets; + const std::regex snippetRegex("(.*)"); + std::sregex_iterator snippetIt(html.begin(), html.end(), snippetRegex); + const std::sregex_iterator end; + for ( ; snippetIt != end; ++snippetIt) + { + const std::smatch snippetMatch = *snippetIt; + snippets.push_back(snippetMatch[1].str()); + } + return snippets; +} + bool isValidSnippet(const std::string& s) { return s.size() >= 250 @@ -731,22 +747,6 @@ struct TestData checkSnippets(extractSearchResultSnippetsFromHtml(html)); } - typedef std::vector Snippets; - - static Snippets extractSearchResultSnippetsFromHtml(const std::string& html) - { - Snippets snippets; - const std::regex snippetRegex("(.*)"); - std::sregex_iterator snippetIt(html.begin(), html.end(), snippetRegex); - const std::sregex_iterator end; - for ( ; snippetIt != end; ++snippetIt) - { - const std::smatch snippetMatch = *snippetIt; - snippets.push_back(snippetMatch[1].str()); - } - return snippets; - } - void checkSnippets(const Snippets& snippets) const { ASSERT_EQ(snippets.size(), results.size());