summaryrefslogtreecommitdiff
path: root/src/fs/virtfs/virtfs1_unittest.cc
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-05-16 19:04:21 +0300
committerAndrei Karas <akaras@inbox.ru>2017-05-16 19:04:21 +0300
commitba71181d5e6fd35083a9e7a86c8e1a9592581398 (patch)
tree9c2751255c652aa444a61a083648537fd9177a41 /src/fs/virtfs/virtfs1_unittest.cc
parent873eff85f179593d486793be24b3cfaf73226e1f (diff)
downloadmv-ba71181d5e6fd35083a9e7a86c8e1a9592581398.tar.gz
mv-ba71181d5e6fd35083a9e7a86c8e1a9592581398.tar.bz2
mv-ba71181d5e6fd35083a9e7a86c8e1a9592581398.tar.xz
mv-ba71181d5e6fd35083a9e7a86c8e1a9592581398.zip
Add subdir support in VirtFs::getFilesWithDir.
Diffstat (limited to 'src/fs/virtfs/virtfs1_unittest.cc')
-rw-r--r--src/fs/virtfs/virtfs1_unittest.cc74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/fs/virtfs/virtfs1_unittest.cc b/src/fs/virtfs/virtfs1_unittest.cc
index c703e3717..a2c7f8590 100644
--- a/src/fs/virtfs/virtfs1_unittest.cc
+++ b/src/fs/virtfs/virtfs1_unittest.cc
@@ -3388,3 +3388,77 @@ TEST_CASE("VirtFs1 getFilesWithDir2")
VirtFs::deinit();
delete2(logger);
}
+
+TEST_CASE("VirtFs1 getFilesWithDir3")
+{
+ VirtFs::init(".");
+ logger = new Logger();
+ std::string name("data/test/test.zip");
+ std::string prefix;
+ if (Files::existsLocal(name) == false)
+ prefix = "../" + prefix;
+
+ VirtFs::mountZip2(prefix + "data/test/test2.zip",
+ "dir",
+ Append_false);
+
+ StringVect list;
+ VirtFs::getFilesWithDir("1", list);
+ REQUIRE(list.size() == 2);
+ REQUIRE(inList(list, "1", "file1.txt"));
+ REQUIRE(inList(list, "1", "test.txt"));
+ list.clear();
+
+ VirtFs::getFilesWithDir(dirSeparator, list);
+ REQUIRE(list.size() == 2);
+ REQUIRE(inList(list, dirSeparator, "dye.png"));
+ REQUIRE(inList(list, dirSeparator, "hide.png"));
+ list.clear();
+
+ VirtFs::unmountZip2(prefix + "data/test/test2.zip",
+ "dir");
+ VirtFs::deinit();
+ delete2(logger);
+}
+
+TEST_CASE("VirtFs1 getFilesWithDir4")
+{
+ VirtFs::init(".");
+ logger = new Logger();
+ std::string name("data/test/test.zip");
+ std::string prefix;
+ if (Files::existsLocal(name) == false)
+ prefix = "../" + prefix;
+ StringVect list;
+
+ SECTION("dir1")
+ {
+ VirtFs::mountDir2(prefix + "data/graphics",
+ "sprites",
+ Append_false);
+
+ VirtFs::getFilesWithDir("/", list);
+ REQUIRE(list.size() <= 16);
+ VirtFs::unmountDir2(prefix + "data/graphics",
+ "sprites");
+ }
+
+ SECTION("dir2")
+ {
+ VirtFs::mountDir2(prefix + "data",
+ "test",
+ Append_false);
+
+ VirtFs::getFilesWithDir("dir1", list);
+ REQUIRE(list.size() <= 6);
+ REQUIRE(list.size() >= 1);
+ REQUIRE(inList(list, "dir1", "file1.txt"));
+ list.clear();
+
+ VirtFs::unmountDir2(prefix + "data",
+ "test");
+ }
+
+ VirtFs::deinit();
+ delete2(logger);
+}