diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-02-28 20:13:55 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-02-28 20:13:55 +0300 |
commit | 993e6f9b9606a71ad35302f0767017fd426c1d0e (patch) | |
tree | 13a8bc658412348d8ea2d248b8d6b6a684f1e541 /src/fs/virtfsphys_unittest.cc | |
parent | c33ecc43f775eebae66e5ad0dc5f9588162b3783 (diff) | |
download | manaplus-993e6f9b9606a71ad35302f0767017fd426c1d0e.tar.gz manaplus-993e6f9b9606a71ad35302f0767017fd426c1d0e.tar.bz2 manaplus-993e6f9b9606a71ad35302f0767017fd426c1d0e.tar.xz manaplus-993e6f9b9606a71ad35302f0767017fd426c1d0e.zip |
Fix files enumeration in root directory in VirtFsZip.
Also add tests for same for other VirtFs functions.
Diffstat (limited to 'src/fs/virtfsphys_unittest.cc')
-rw-r--r-- | src/fs/virtfsphys_unittest.cc | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/fs/virtfsphys_unittest.cc b/src/fs/virtfsphys_unittest.cc index a70402668..d9821d350 100644 --- a/src/fs/virtfsphys_unittest.cc +++ b/src/fs/virtfsphys_unittest.cc @@ -174,6 +174,61 @@ TEST_CASE("VirtFsPhys enumerateFiles2") delete2(logger); } +static bool inList(VirtList *list, + const std::string &name) +{ + FOR_EACH (StringVectCIter, it, list->names) + { + if (*it == name) + return true; + } + return false; +} + +TEST_CASE("VirtFsPhys enumerateFiles3") +{ + VirtFsPhys::initFuncs(); + logger = new Logger; + + VirtFsPhys::addZipToSearchPath("data/test/test.zip", + Append_false); + VirtFsPhys::addZipToSearchPath("../data/test/test.zip", + Append_false); + + VirtList *list = nullptr; + + list = VirtFsPhys::enumerateFiles("/"); + REQUIRE(inList(list, "units.xml") == false); + REQUIRE(inList(list, "test.txt") == false); + VirtFsPhys::freeList(list); + + VirtFsPhys::removeZipFromSearchPath("data/test/test.zip"); + VirtFsPhys::removeZipFromSearchPath("../data/test/test.zip"); + delete2(logger); +} + +TEST_CASE("VirtFsPhys enumerateFiles4") +{ + VirtFsPhys::initFuncs(); + logger = new Logger; + + VirtFsPhys::addZipToSearchPath("data/test/test2.zip", + Append_false); + VirtFsPhys::addZipToSearchPath("../data/test/test2.zip", + Append_false); + + VirtList *list = nullptr; + + list = VirtFsPhys::enumerateFiles("/"); + REQUIRE(inList(list, "units.xml") == true); + REQUIRE(inList(list, "test.txt") == true); + VirtFsPhys::freeList(list); + + VirtFsPhys::removeZipFromSearchPath("data/test/test2.zip"); + VirtFsPhys::removeZipFromSearchPath("../data/test/test2.zip"); + delete2(logger); +} + TEST_CASE("VirtFsPhys isDirectory") { VirtFsPhys::initFuncs(); |