From d8fe593f59e3c38087bca172eec4030a5260b285 Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Sun, 11 Apr 2021 15:32:16 +0400 Subject: [PATCH] Extended the unit-test library with 2 XML entries --- test/library.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 7 deletions(-) diff --git a/test/library.cpp b/test/library.cpp index ad0bca605..1040f25f9 100644 --- a/test/library.cpp +++ b/test/library.cpp @@ -181,6 +181,43 @@ const char * sampleOpdsStream = R"( )"; +const char sampleLibraryXML[] = R"( + + + + +)"; + #include "../include/library.h" #include "../include/manager.h" #include "../include/bookmark.h" @@ -196,6 +233,7 @@ class LibraryTest : public ::testing::Test { void SetUp() override { kiwix::Manager manager(&lib); manager.readOpds(sampleOpdsStream, "foo.urlHost"); + manager.readXml(sampleLibraryXML, true, "/data/library.xml", true); } kiwix::Bookmark createBookmark(const std::string &id) { @@ -237,10 +275,10 @@ TEST_F(LibraryTest, getBookMarksTest) TEST_F(LibraryTest, sanityCheck) { - EXPECT_EQ(lib.getBookCount(true, true), 10U); - EXPECT_EQ(lib.getBooksLanguages().size(), 2U); - EXPECT_EQ(lib.getBooksCreators().size(), 8U); - EXPECT_EQ(lib.getBooksPublishers().size(), 1U); + EXPECT_EQ(lib.getBookCount(true, true), 12U); + EXPECT_EQ(lib.getBooksLanguages().size(), 3U); + EXPECT_EQ(lib.getBooksCreators().size(), 9U); + EXPECT_EQ(lib.getBooksPublishers().size(), 2U); } TEST_F(LibraryTest, categoryHandling) @@ -271,6 +309,7 @@ TEST_F(LibraryTest, filterByLanguage) "Islam Stack Exchange", "Movies & TV Stack Exchange", "Mythology & Folklore Stack Exchange", + "Ray Charles", "TED talks - Business" ); } @@ -305,7 +344,8 @@ TEST_F(LibraryTest, filterByTags) EXPECT_FILTER_RESULTS(kiwix::Filter().acceptTags({"wikipedia"}), "Encyclopédie de la Tunisie", "Géographie par Wikipédia", - "Mathématiques" + "Mathématiques", + "Ray Charles" ); EXPECT_FILTER_RESULTS(kiwix::Filter().acceptTags({"wikipedia", "nopic"}), @@ -314,7 +354,8 @@ TEST_F(LibraryTest, filterByTags) ); EXPECT_FILTER_RESULTS(kiwix::Filter().acceptTags({"wikipedia"}).rejectTags({"nopic"}), - "Encyclopédie de la Tunisie" + "Encyclopédie de la Tunisie", + "Ray Charles" ); } @@ -352,6 +393,7 @@ TEST_F(LibraryTest, filterByQuery) "Encyclopédie de la Tunisie", "Granblue Fantasy Wiki", "Géographie par Wikipédia", + "Ray Charles", "Wikiquote" ); @@ -367,7 +409,8 @@ TEST_F(LibraryTest, filterByCreator) EXPECT_FILTER_RESULTS(kiwix::Filter().creator("Wikipedia"), "Encyclopédie de la Tunisie", "Géographie par Wikipédia", - "Mathématiques" + "Mathématiques", + "Ray Charles" ); // filtering by creator requires full match of the search term