mirror of
https://github.com/kiwix/libkiwix.git
synced 2025-06-26 10:11:30 +00:00
Two unit-tests for Library::removeBookById
The `XmlLibraryTest.removeBookByIdDropsTheReader` unit-test fails, demonstrating a bug in `kiwix::Library::removeBookById()`.
This commit is contained in:
@ -283,4 +283,31 @@ TEST_F(LibraryTest, getBookByPath)
|
|||||||
EXPECT_EQ(lib.getBookByPath(path).getId(), book.getId());
|
EXPECT_EQ(lib.getBookByPath(path).getId(), book.getId());
|
||||||
EXPECT_THROW(lib.getBookByPath("non/existant/path.zim"), std::out_of_range);
|
EXPECT_THROW(lib.getBookByPath("non/existant/path.zim"), std::out_of_range);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class XmlLibraryTest : public ::testing::Test {
|
||||||
|
protected:
|
||||||
|
void SetUp() override {
|
||||||
|
kiwix::Manager manager(&lib);
|
||||||
|
manager.readFile( "./test/library.xml", true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
kiwix::Library lib;
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(XmlLibraryTest, removeBookByIdRemovesTheBook)
|
||||||
|
{
|
||||||
|
EXPECT_EQ(3U, lib.getBookCount(true, true));
|
||||||
|
EXPECT_NO_THROW(lib.getBookById("raycharles"));
|
||||||
|
lib.removeBookById("raycharles");
|
||||||
|
EXPECT_EQ(2U, lib.getBookCount(true, true));
|
||||||
|
EXPECT_THROW(lib.getBookById("raycharles"), std::out_of_range);
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(XmlLibraryTest, removeBookByIdDropsTheReader)
|
||||||
|
{
|
||||||
|
EXPECT_NE(nullptr, lib.getReaderById("raycharles"));
|
||||||
|
lib.removeBookById("raycharles");
|
||||||
|
EXPECT_THROW(lib.getReaderById("raycharles"), std::out_of_range);
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user