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:
Maneesh P M 2021-08-04 12:36:00 +05:30
parent a032d65eb8
commit e74e7f5623
1 changed files with 28 additions and 11 deletions

View File

@ -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);
}
} }