mirror of https://github.com/kiwix/libkiwix.git
Add unit test for incremental searching
With this, we eventually want to see the usage of getResults giving a FAILING TEST. This happens because the second argument to getResults is NOT `end` of the range, but `maxResultCount` to retrieve. This will be fixed in the next commit.
This commit is contained in:
parent
a032d65eb8
commit
e74e7f5623
|
@ -22,4 +22,21 @@ TEST(Searcher, search) {
|
||||||
ASSERT_EQ(result->get_title(), "Wikibooks");
|
ASSERT_EQ(result->get_title(), "Wikibooks");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(Searcher, incrementalRange) {
|
||||||
|
// Attempt to get 50 results in steps of 5
|
||||||
|
zim::Archive archive("./test/zimfile.zim");
|
||||||
|
zim::Searcher ftsearcher(archive);
|
||||||
|
zim::Query query;
|
||||||
|
query.setQuery("ray", false);
|
||||||
|
auto search = ftsearcher.search(query);
|
||||||
|
|
||||||
|
int suggCount = 0;
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
auto srs = search.getResults(i*5, (i + 1)*5); // get 5 results
|
||||||
|
ASSERT_EQ(srs.size(), 5);
|
||||||
|
suggCount += srs.size();
|
||||||
|
}
|
||||||
|
ASSERT_EQ(suggCount, 50);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue