#include "fs-compat.hpp" #include "zip.hpp" #include #include #include #include #include SCENARIO("epubgrep::zip::list() doesn't fail and returns the right file list") { std::setlocale(LC_CTYPE, ""); // Needed for utf-8 support in libarchive. bool exception{false}; std::vector filelist; GIVEN("Our test zip file") { fs::path zipfile{"test.zip"}; REQUIRE(fs::exists(zipfile)); WHEN("We list the file contents") { try { filelist = epubgrep::zip::list(zipfile); } catch (const std::exception &) { exception = true; } THEN("No exception is thrown") AND_THEN("It returns the file contents correctly") { REQUIRE_FALSE(exception); REQUIRE(filelist.at(0) == "test folder/"); REQUIRE(filelist.at(1) == "test folder/test file"); REQUIRE(filelist.at(2) == "test folder/😊"); } } } }