summaryrefslogtreecommitdiff
path: root/src/fs/virtfs/virtfs1_unittest.cc
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-04-24 03:35:02 +0300
committerAndrei Karas <akaras@inbox.ru>2017-04-24 04:35:35 +0300
commit0835e09ee3a6c83ffa01454f2c05597e6195b07d (patch)
treeb3b79b7a8f58f2ff18ec66b17d1c39ddad085e11 /src/fs/virtfs/virtfs1_unittest.cc
parent55458f743c3ff7e42288bc08033481d8464dca62 (diff)
downloadplus-0835e09ee3a6c83ffa01454f2c05597e6195b07d.tar.gz
plus-0835e09ee3a6c83ffa01454f2c05597e6195b07d.tar.bz2
plus-0835e09ee3a6c83ffa01454f2c05597e6195b07d.tar.xz
plus-0835e09ee3a6c83ffa01454f2c05597e6195b07d.zip
Improve VirtFs::getFiles.
Diffstat (limited to 'src/fs/virtfs/virtfs1_unittest.cc')
-rw-r--r--src/fs/virtfs/virtfs1_unittest.cc73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/fs/virtfs/virtfs1_unittest.cc b/src/fs/virtfs/virtfs1_unittest.cc
index d7a0d341c..a267f2b5a 100644
--- a/src/fs/virtfs/virtfs1_unittest.cc
+++ b/src/fs/virtfs/virtfs1_unittest.cc
@@ -684,6 +684,17 @@ static bool inList(const VirtList *const list,
return false;
}
+static bool inList(StringVect list,
+ const std::string &name)
+{
+ FOR_EACH (StringVectCIter, it, list)
+ {
+ if (*it == name)
+ return true;
+ }
+ return false;
+}
+
TEST_CASE("VirtFs1 enumerateFiles1")
{
VirtFs::init(".");
@@ -919,6 +930,37 @@ TEST_CASE("VirtFsZip enumerateFiles8")
delete2(logger);
}
+TEST_CASE("VirtFsZip enumerateFiles9")
+{
+ VirtFs::init(".");
+ logger = new Logger;
+ std::string name("data/test/test.zip");
+ std::string prefix;
+ if (Files::existsLocal(name) == false)
+ prefix = "../" + prefix;
+
+ VirtFs::mountZip(prefix + "data/test/test2.zip",
+ Append_false);
+ VirtFs::mountDirSilent(prefix + "data/test",
+ Append_false);
+
+ VirtList *list = nullptr;
+
+ list = VirtFs::enumerateFiles("dir");
+ REQUIRE(list->names.size() == 4);
+ REQUIRE(inList(list, "1"));
+ REQUIRE(inList(list, "gpl"));
+ REQUIRE(inList(list, "dye.png"));
+ REQUIRE(inList(list, "hide.png"));
+ VirtFs::freeList(list);
+
+ VirtFs::unmountZip(prefix + "data/test/test2.zip");
+ VirtFs::unmountDir(prefix + "data/test");
+ VirtFs::deinit();
+ delete2(logger);
+}
+
+
TEST_CASE("VirtFs1 isDirectory1")
{
VirtFs::init(".");
@@ -1872,3 +1914,34 @@ TEST_CASE("VirtFs1 rwops_read3")
VirtFs::deinit();
delete2(logger);
}
+
+TEST_CASE("VirtFs1 getFiles zip")
+{
+ VirtFs::init(".");
+ logger = new Logger();
+ std::string name("data/test/test.zip");
+ std::string prefix;
+ if (Files::existsLocal(name) == false)
+ prefix = "../" + prefix;
+
+ VirtFs::mountZip(prefix + "data/test/test2.zip",
+ Append_false);
+
+ StringVect list;
+ VirtFs::getFiles("dir", list);
+ REQUIRE(list.size() == 2);
+ REQUIRE(inList(list, "dye.png"));
+ REQUIRE(inList(list, "hide.png"));
+
+ list.clear();
+ VirtFs::getFiles("dir2", list);
+ REQUIRE(inList(list, "hide.png"));
+ REQUIRE(inList(list, "paths.xml"));
+ REQUIRE(inList(list, "test.txt"));
+ REQUIRE(inList(list, "units.xml"));
+ REQUIRE(list.size() == 4);
+
+ VirtFs::unmountZip(prefix + "data/test/test2.zip");
+ VirtFs::deinit();
+ delete2(logger);
+}