From b60b3123345a619aab656c1c361c2c8c42e6455c Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 16 May 2017 04:28:44 +0300 Subject: Add subdir support into VirtFs::enumerateFiles. --- src/fs/virtfs/virtfs1_unittest.cc | 100 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) (limited to 'src/fs/virtfs/virtfs1_unittest.cc') diff --git a/src/fs/virtfs/virtfs1_unittest.cc b/src/fs/virtfs/virtfs1_unittest.cc index 264f92079..57d82e9af 100644 --- a/src/fs/virtfs/virtfs1_unittest.cc +++ b/src/fs/virtfs/virtfs1_unittest.cc @@ -1754,6 +1754,106 @@ TEST_CASE("VirtFsZip enumerateFiles9") delete2(logger); } +TEST_CASE("VirtFsZip enumerateFiles10") +{ + VirtFs::init("."); + logger = new Logger; + std::string name("data/test/test.zip"); + std::string prefix("data\\test/"); + if (Files::existsLocal(name) == false) + prefix = "../" + prefix; + + VirtFs::mountZip2(prefix + "test.zip", + "dir", + Append_false); + + VirtFs::List *list = nullptr; + + list = VirtFs::enumerateFiles("/"); + REQUIRE(list->names.size() == 2); + REQUIRE(inList(list, "brimmedhat.png")); + REQUIRE(inList(list, "hide.png")); + VirtFs::freeList(list); + + VirtFs::unmountZip2(prefix + "test.zip", + "dir"); + VirtFs::deinit(); + delete2(logger); +} + +TEST_CASE("VirtFsZip enumerateFiles11") +{ + VirtFs::init("."); + logger = new Logger; + std::string name("data/test/test.zip"); + std::string prefix("data\\test/"); + if (Files::existsLocal(name) == false) + prefix = "../" + prefix; + + VirtFs::mountZip2(prefix + "test2.zip", + "dir", + Append_false); + + VirtFs::List *list = nullptr; + + list = VirtFs::enumerateFiles("1"); + REQUIRE(list->names.size() == 2); + REQUIRE(inList(list, "file1.txt")); + REQUIRE(inList(list, "test.txt")); + VirtFs::freeList(list); + + VirtFs::unmountZip2(prefix + "test2.zip", + "dir"); + VirtFs::deinit(); + delete2(logger); +} + +TEST_CASE("VirtFs1 enumerateFiles12") +{ + VirtFs::init("."); + logger = new Logger; + + VirtFs::mountDirSilent2("data/test", + "dir2", + Append_false); + VirtFs::mountDirSilent2("../data/test", + "dir2", + Append_false); + + VirtFs::List *list = nullptr; + + list = VirtFs::enumerateFiles("/"); + REQUIRE(inList(list, "file1.txt")); + REQUIRE(inList(list, "file2.txt")); + VirtFs::freeList(list); + + VirtFs::deinit(); + delete2(logger); +} + +TEST_CASE("VirtFs1 enumerateFiles13") +{ + VirtFs::init("."); + logger = new Logger; + + VirtFs::mountDirSilent2("data", + "test", + Append_false); + VirtFs::mountDirSilent2("../data", + "test", + Append_false); + + VirtFs::List *list = nullptr; + + list = VirtFs::enumerateFiles("dir2"); + REQUIRE(inList(list, "file1.txt")); + REQUIRE(inList(list, "file2.txt")); + VirtFs::freeList(list); + + VirtFs::deinit(); + delete2(logger); +} + TEST_CASE("VirtFs1 isDirectory1") { -- cgit v1.2.3-70-g09d2