mirror of
https://github.com/kiwix/libkiwix.git
synced 2025-06-28 05:49:35 +00:00
Add unit tests for Searcher and Reader
Even though we will be removing the wrappers soon, the test coverage should be complete and we could simply remove these files later.
This commit is contained in:
25
test/searcher.cpp
Normal file
25
test/searcher.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include "../include/searcher.h"
|
||||
#include "../include/reader.h"
|
||||
|
||||
namespace kiwix
|
||||
{
|
||||
|
||||
TEST(Searcher, search) {
|
||||
Reader reader("./test/example.zim");
|
||||
|
||||
Searcher searcher;
|
||||
searcher.add_reader(&reader);
|
||||
ASSERT_EQ(searcher.get_reader(0)->getTitle(), reader.getTitle());
|
||||
|
||||
searcher.search("wiki", 0, 2);
|
||||
searcher.restart_search();
|
||||
ASSERT_EQ(searcher.getEstimatedResultCount(), (unsigned int)2);
|
||||
|
||||
auto result = searcher.getNextResult();
|
||||
ASSERT_EQ(result->get_title(), "FreedomBox for Communities/Offline Wikipedia - Wikibooks, open books for an open world");
|
||||
result = searcher.getNextResult();
|
||||
ASSERT_EQ(result->get_title(), "Wikibooks");
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user