mirror of https://github.com/kiwix/libkiwix.git
Two unit-tests for Library::removeBookById
The `XmlLibraryTest.removeBookByIdDropsTheReader` unit-test fails, demonstrating a bug in `kiwix::Library::removeBookById()`.
This commit is contained in:
parent
ba44033273
commit
ccdc316217
|
@ -283,4 +283,31 @@ TEST_F(LibraryTest, getBookByPath)
|
|||
EXPECT_EQ(lib.getBookByPath(path).getId(), book.getId());
|
||||
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);
|
||||
};
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue