Skip to content

Commit

Permalink
Add test on multi part embedded file.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgautierfr committed Feb 26, 2024
1 parent d2575fe commit 7b417db
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/archive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,33 @@ TEST(ZimArchive, openZIMFileEmbeddedInAnotherFile)
checkEquivalence(archive1, archive2);
}
}

TEST(ZimArchive, openZIMFileMultiPartEmbeddedInAnotherFile)
{
auto normalZims = getDataFilePath("small.zim");
auto embeddedZims = getDataFilePath("small.zim.embedded.multi");

ASSERT_EQ(normalZims.size(), embeddedZims.size()) << "We must have same number of zim files. (This is a test data issue)";
for(auto i=0UL; i < normalZims.size(); i++) {
const zim::Archive archive1(normalZims[i].path);
auto archive_size = archive1.getFilesize();

std::vector<zim::FdInput> fds;
zim::offset_type start_offset = std::string("BEGINZIMMULTIPART").size();
while (archive_size > 2048) {
int fd = OPEN_READ_ONLY(embeddedZims[i].path);
fds.push_back(zim::FdInput(fd, start_offset, 2048));
start_offset += 2048 + std::string("NEWSECTIONZIMMULTI").size();
archive_size -= 2048;
}
int fd = OPEN_READ_ONLY(embeddedZims[i].path);
fds.push_back(zim::FdInput(fd, start_offset, archive_size));

const zim::Archive archive2(fds);

checkEquivalence(archive1, archive2);
}
}
#endif // not _WIN32
#endif // WITH_TEST_DATA

Expand Down

0 comments on commit 7b417db

Please sign in to comment.