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/virtfs_unittest.cc | |
parent | c33ecc43f775eebae66e5ad0dc5f9588162b3783 (diff) | |
download | plus-993e6f9b9606a71ad35302f0767017fd426c1d0e.tar.gz plus-993e6f9b9606a71ad35302f0767017fd426c1d0e.tar.bz2 plus-993e6f9b9606a71ad35302f0767017fd426c1d0e.tar.xz plus-993e6f9b9606a71ad35302f0767017fd426c1d0e.zip |
Fix files enumeration in root directory in VirtFsZip.
Also add tests for same for other VirtFs functions.
Diffstat (limited to 'src/fs/virtfs_unittest.cc')
-rw-r--r-- | src/fs/virtfs_unittest.cc | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/fs/virtfs_unittest.cc b/src/fs/virtfs_unittest.cc index 5b9da2394..7e079e212 100644 --- a/src/fs/virtfs_unittest.cc +++ b/src/fs/virtfs_unittest.cc @@ -106,6 +106,17 @@ static void removeTemp(StringVect &restrict list) } } +static bool inList(VirtList *list, + const std::string &name) +{ + FOR_EACH (StringVectCIter, it, list->names) + { + if (*it == name) + return true; + } + return false; +} + TEST_CASE("VirtFs enumerateFiles1") { logger = new Logger; @@ -163,6 +174,51 @@ TEST_CASE("VirtFs enumerateFiles2") delete2(logger); } +TEST_CASE("VirtFs enumerateFiles3") +{ + logger = new Logger; + + VirtFs::addZipToSearchPath("data/test/test.zip", + Append_false); + VirtFs::addZipToSearchPath("../data/test/test.zip", + Append_false); + + VirtList *list = nullptr; + + list = VirtFs::enumerateFiles("/"); + REQUIRE(list->names.size() == 1); + REQUIRE(inList(list, "dir")); + VirtFs::freeList(list); + + VirtFs::removeZipFromSearchPath("data/test/test.zip"); + VirtFs::removeZipFromSearchPath("../data/test/test.zip"); + delete2(logger); +} + +TEST_CASE("VirtFs enumerateFiles4") +{ + logger = new Logger; + + VirtFs::addZipToSearchPath("data/test/test2.zip", + Append_false); + VirtFs::addZipToSearchPath("../data/test/test2.zip", + Append_false); + + VirtList *list = nullptr; + + list = VirtFs::enumerateFiles("/"); + REQUIRE(list->names.size() == 4); + REQUIRE(inList(list, "dir")); + REQUIRE(inList(list, "dir2")); + REQUIRE(inList(list, "test.txt")); + REQUIRE(inList(list, "units.xml")); + VirtFs::freeList(list); + + VirtFs::removeZipFromSearchPath("data/test/test2.zip"); + VirtFs::removeZipFromSearchPath("../data/test/test2.zip"); + delete2(logger); +} + TEST_CASE("VirtFs isDirectory") { logger = new Logger(); |