mirror of https://github.com/kiwix/libkiwix.git
Enhanced the LibraryTest.filterByQuery unit-test
This commit is contained in:
parent
8c18a37961
commit
8c810d2d2f
|
@ -311,14 +311,45 @@ TEST_F(LibraryTest, filterByTags)
|
||||||
|
|
||||||
TEST_F(LibraryTest, filterByQuery)
|
TEST_F(LibraryTest, filterByQuery)
|
||||||
{
|
{
|
||||||
auto bookIds = lib.filter(kiwix::Filter().query("folklore"));
|
// filtering by query checks the title
|
||||||
|
auto bookIds = lib.filter(kiwix::Filter().query("Exchange"));
|
||||||
EXPECT_EQ(ids2Titles(bookIds),
|
EXPECT_EQ(ids2Titles(bookIds),
|
||||||
TitleCollection({
|
TitleCollection({
|
||||||
|
"Islam Stack Exchange",
|
||||||
|
"Movies & TV Stack Exchange",
|
||||||
"Mythology & Folklore Stack Exchange"
|
"Mythology & Folklore Stack Exchange"
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// filtering by query checks the description/summary
|
||||||
|
bookIds = lib.filter(kiwix::Filter().query("enthusiasts"));
|
||||||
|
EXPECT_EQ(ids2Titles(bookIds),
|
||||||
|
TitleCollection({
|
||||||
|
"Movies & TV Stack Exchange",
|
||||||
|
"Mythology & Folklore Stack Exchange"
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
// filtering by query is case insensitive on titles
|
||||||
|
bookIds = lib.filter(kiwix::Filter().query("ExcHANge"));
|
||||||
|
EXPECT_EQ(ids2Titles(bookIds),
|
||||||
|
TitleCollection({
|
||||||
|
"Islam Stack Exchange",
|
||||||
|
"Movies & TV Stack Exchange",
|
||||||
|
"Mythology & Folklore Stack Exchange"
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
// filtering by query is case insensitive on description/summary
|
||||||
|
bookIds = lib.filter(kiwix::Filter().query("enTHUSiaSTS"));
|
||||||
|
EXPECT_EQ(ids2Titles(bookIds),
|
||||||
|
TitleCollection({
|
||||||
|
"Movies & TV Stack Exchange",
|
||||||
|
"Mythology & Folklore Stack Exchange"
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
// by default, filtering by query assumes partial query
|
||||||
bookIds = lib.filter(kiwix::Filter().query("Wiki"));
|
bookIds = lib.filter(kiwix::Filter().query("Wiki"));
|
||||||
EXPECT_EQ(ids2Titles(bookIds),
|
EXPECT_EQ(ids2Titles(bookIds),
|
||||||
TitleCollection({
|
TitleCollection({
|
||||||
|
@ -328,6 +359,14 @@ TEST_F(LibraryTest, filterByQuery)
|
||||||
"Wikiquote"
|
"Wikiquote"
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// partial query can be disabled
|
||||||
|
bookIds = lib.filter(kiwix::Filter().query("Wiki", false));
|
||||||
|
EXPECT_EQ(ids2Titles(bookIds),
|
||||||
|
TitleCollection({
|
||||||
|
"Granblue Fantasy Wiki"
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue