diff --git a/test/server_html_search.cpp b/test/server_html_search.cpp
index b4862916d..20873eaec 100644
--- a/test/server_html_search.cpp
+++ b/test/server_html_search.cpp
@@ -137,15 +137,32 @@ std::string makeSearchResultsHtml(const std::string& pattern,
return html;
}
-#define SEARCH_RESULT(LINK, TITLE, SNIPPET, BOOK_TITLE, WORDCOUNT) \
-"\n \n"\
-" " TITLE "\n"\
-" \n"\
-" " SNIPPET "\n"\
-"
from " BOOK_TITLE "
\n"\
-" " WORDCOUNT " words
\n"
+struct SearchResult
+{
+ std::string link;
+ std::string title;
+ std::string snippet;
+ std::string bookTitle;
+ std::string wordCount;
-const std::vector LARGE_SEARCH_RESULTS = {
+ std::string getHtml() const
+ {
+ return std::string()
+ + "\n \n"
+ + " " + title + "\n"
+ + " \n"
+ + " " + snippet + "\n"
+ + " from " + bookTitle + "
\n"
+ + " " + wordCount + " words
\n";
+ }
+};
+
+#define SEARCH_RESULT(LINK, TITLE, SNIPPET, BOOK_TITLE, WORDCOUNT) \
+ SearchResult{LINK, TITLE, SNIPPET, BOOK_TITLE, WORDCOUNT}
+
+
+
+const std::vector LARGE_SEARCH_RESULTS = {
SEARCH_RESULT(
/*link*/ "/ROOT/zimfile/A/Genius_+_Soul_=_Jazz",
/*title*/ "Genius + Soul = Jazz",
@@ -597,7 +614,7 @@ struct TestData
size_t resultsPerPage;
size_t totalResultCount;
size_t firstResultIndex;
- std::vector results;
+ std::vector results;
std::vector pagination;
static std::string makeUrl(const std::string& query, int start, size_t resultsPerPage)
@@ -661,7 +678,7 @@ struct TestData
std::string s;
for ( const auto& r : results ) {
s += "\n ";
- s += maskSnippetsInSearchResults(r);
+ s += maskSnippetsInSearchResults(r.getHtml());
s += " ";
}
return s;
@@ -736,14 +753,9 @@ struct TestData
for ( size_t i = 0; i < results.size(); ++i )
{
const auto& r = results[i];
- const auto expectedSnippet = extractSearchResultSnippets(r);
- ASSERT_EQ(1u, expectedSnippet.size())
- << "Multiple snippets in test data:"
- << "\n" << r;
-
- if ( snippets[i] != expectedSnippet[0] ) {
+ if ( snippets[i] != r.snippet ) {
std::cout << "Trying a weaker check for a mismatching snippet...\n";
- checkMismatchingSnippet(snippets[i], expectedSnippet[0]);
+ checkMismatchingSnippet(snippets[i], r.snippet);
}
}
}