summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-07-18 20:46:12 +0300
committerAndrei Karas <akaras@inbox.ru>2017-07-18 20:46:12 +0300
commitacc4afeab30c559fa111f102e2db006039e249e2 (patch)
treeb966715d4eae057dc3afeaff0424b956ae6a067a
parentdc91c490958be3571b6f3a151bec1b926ebe0d91 (diff)
downloadplus-acc4afeab30c559fa111f102e2db006039e249e2.tar.gz
plus-acc4afeab30c559fa111f102e2db006039e249e2.tar.bz2
plus-acc4afeab30c559fa111f102e2db006039e249e2.tar.xz
plus-acc4afeab30c559fa111f102e2db006039e249e2.zip
Split virtfs mount unit tests into two files.
-rw-r--r--src/Makefile.am3
-rw-r--r--src/unittests/fs/virtfs/virtfs1_mountdir.cc (renamed from src/unittests/fs/virtfs/virtfs1_mount.cc)297
-rw-r--r--src/unittests/fs/virtfs/virtfs1_mountzip.cc332
3 files changed, 334 insertions, 298 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 87f5b09a3..fe9a52b3d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2058,7 +2058,8 @@ manaplustests_SOURCES += \
unittests/fs/virtfs/virtfs1_enumerate.cc \
unittests/fs/virtfs/virtfs1_exists.cc \
unittests/fs/virtfs/virtfs1_getrealdir.cc \
- unittests/fs/virtfs/virtfs1_mount.cc \
+ unittests/fs/virtfs/virtfs1_mountdir.cc \
+ unittests/fs/virtfs/virtfs1_mountzip.cc \
unittests/fs/virtfs/virtfs1_unmount.cc \
unittests/fs/virtfs/virtfs2_unittest.cc \
unittests/fs/virtfs/zip_unittest.cc \
diff --git a/src/unittests/fs/virtfs/virtfs1_mount.cc b/src/unittests/fs/virtfs/virtfs1_mountdir.cc
index 6b3a50e80..13407d2a1 100644
--- a/src/unittests/fs/virtfs/virtfs1_mount.cc
+++ b/src/unittests/fs/virtfs/virtfs1_mountdir.cc
@@ -474,300 +474,3 @@ TEST_CASE("VirtFs1 mountDir", "")
VirtFs::deinit();
delete2(logger);
}
-
-TEST_CASE("VirtFs1 mountZip", "")
-{
- VirtFs::init(".");
- logger = new Logger();
- std::string name("data/test/test.zip");
- std::string prefix;
- const std::string sep = dirSeparator;
- if (Files::existsLocal(name) == false)
- prefix = "../";
-
- SECTION("simple 1")
- {
- REQUIRE(VirtFs::mountZip(prefix + "data/test/test.zip",
- Append_false));
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test.zip", std::string()) !=
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test2.zip",
- std::string()) == nullptr);
- REQUIRE(VirtFs::getEntries().size() == 1);
- REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data" + sep + "test" + sep + "test.zip");
- REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
- }
-
- SECTION("simple 2")
- {
- REQUIRE(VirtFs::mountZip(prefix + "data/test/test.zip",
- Append_false));
- REQUIRE(VirtFs::mountZip(prefix + "data/test/test2.zip",
- Append_false));
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test.zip",
- std::string()) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test2.zip",
- std::string()) != nullptr);
- REQUIRE(VirtFs::getEntries().size() == 2);
- REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data" + sep + "test" + sep + "test2.zip");
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[1]->root ==
- prefix + "data" + sep + "test" + sep + "test.zip");
- REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[1]->subDir.empty());
- }
-
- SECTION("simple 3")
- {
- REQUIRE(VirtFs::mountZip(prefix + "data/test/test.zip",
- Append_true));
- REQUIRE(VirtFs::mountZip(prefix + "data/test/test2.zip",
- Append_true));
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test.zip",
- std::string()) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test2.zip",
- std::string()) != nullptr);
- REQUIRE(VirtFs::getEntries().size() == 2);
- REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data" + sep + "test" + sep + "test.zip");
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[1]->root ==
- prefix + "data" + sep + "test" + sep + "test2.zip");
- REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[1]->subDir.empty());
- }
-
- SECTION("simple 4")
- {
- REQUIRE(VirtFs::mountZip(prefix + "data/test/test.zip",
- Append_false));
- REQUIRE(VirtFs::mountDir(prefix + "data/test",
- Append_false));
- REQUIRE(VirtFs::mountZip(prefix + "data/test/test2.zip",
- Append_false));
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test.zip",
- std::string()) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test2.zip",
- std::string()) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "",
- std::string()) != nullptr);
- REQUIRE(VirtFs::getEntries().size() == 3);
- REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data" + sep + "test" + sep + "test2.zip");
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[1]->root ==
- prefix + "data" + sep + "test" + sep + "");
- REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[1]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[2]->root ==
- prefix + "data" + sep + "test" + sep + "test.zip");
- REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[2]->subDir.empty());
- }
-
- SECTION("simple 5")
- {
- REQUIRE(VirtFs::mountZip(prefix + "data/test/test.zip",
- Append_false));
- REQUIRE(VirtFs::mountDir(prefix + "data/test",
- Append_false));
- REQUIRE(VirtFs::mountZip(prefix + "data/test/test2.zip",
- Append_true));
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test.zip",
- std::string()) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test2.zip",
- std::string()) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "",
- std::string()) != nullptr);
- REQUIRE(VirtFs::getEntries().size() == 3);
- REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data" + sep + "test" + sep + "");
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[1]->root ==
- prefix + "data" + sep + "test" + sep + "test.zip");
- REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[1]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[2]->root ==
- prefix + "data" + sep + "test" + sep + "test2.zip");
- REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[2]->subDir.empty());
- }
-
- SECTION("subDir 1")
- {
- REQUIRE(VirtFs::mountZip2(prefix + "data/test/test.zip",
- "dir1",
- Append_false));
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test.zip", "dir1" + sep) !=
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test2.zip",
- std::string()) == nullptr);
- REQUIRE(VirtFs::getEntries().size() == 1);
- REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data" + sep + "test" + sep + "test.zip");
- REQUIRE(VirtFs::getEntries()[0]->subDir == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
- }
-
- SECTION("subDir 2")
- {
- REQUIRE(VirtFs::mountZip2(prefix + "data/test/test.zip",
- "dir1",
- Append_false));
- REQUIRE(VirtFs::mountZip2(prefix + "data/test/test2.zip",
- "dir2",
- Append_false));
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test.zip", "dir1" + sep) !=
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test2.zip",
- "dir2" + sep) != nullptr);
- REQUIRE(VirtFs::getEntries().size() == 2);
- REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data" + sep + "test" + sep + "test2.zip");
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[0]->subDir == "dir2" + sep);
- REQUIRE(VirtFs::getEntries()[1]->root ==
- prefix + "data" + sep + "test" + sep + "test.zip");
- REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[1]->subDir == "dir1" + sep);
- }
-
- SECTION("subDir 3")
- {
- REQUIRE(VirtFs::mountZip2(prefix + "data/test/test.zip",
- "dir1",
- Append_true));
- REQUIRE(VirtFs::mountZip2(prefix + "data/test/test2.zip",
- "dir2",
- Append_true));
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test.zip",
- "dir1" + sep) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test2.zip",
- "dir2" + sep) != nullptr);
- REQUIRE(VirtFs::getEntries().size() == 2);
- REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data" + sep + "test" + sep + "test.zip");
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[0]->subDir == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[1]->root ==
- prefix + "data" + sep + "test" + sep + "test2.zip");
- REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[1]->subDir == "dir2" + sep);
- }
-
- SECTION("subDir 4")
- {
- REQUIRE(VirtFs::mountZip2(prefix + "data/test/test.zip",
- "dir1",
- Append_false));
- REQUIRE(VirtFs::mountDir2(prefix + "data/test",
- "dir2",
- Append_false));
- REQUIRE(VirtFs::mountZip2(prefix + "data/test/test2.zip",
- "dir3",
- Append_false));
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test.zip",
- "dir1" + sep) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test2.zip",
- "dir3" + sep) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "",
- "dir2" + sep) != nullptr);
- REQUIRE(VirtFs::getEntries().size() == 3);
- REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data" + sep + "test" + sep + "test2.zip");
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[0]->subDir == "dir3" + sep);
- REQUIRE(VirtFs::getEntries()[1]->root ==
- prefix + "data" + sep + "test" + sep + "");
- REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[1]->subDir == "dir2" + sep);
- REQUIRE(VirtFs::getEntries()[2]->root ==
- prefix + "data" + sep + "test" + sep + "test.zip");
- REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[2]->subDir == "dir1" + sep);
- }
-
- SECTION("subDir 5")
- {
- REQUIRE(VirtFs::mountZip2(prefix + "data/test/test.zip",
- "dir1",
- Append_false));
- REQUIRE(VirtFs::mountDir2(prefix + "data/test",
- "dir2",
- Append_false));
- REQUIRE(VirtFs::mountZip2(prefix + "data/test/test2.zip",
- "dir3",
- Append_true));
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test.zip",
- "dir1" + sep) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test2.zip",
- "dir3" + sep) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "",
- "dir2" + sep) != nullptr);
- REQUIRE(VirtFs::getEntries().size() == 3);
- REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data" + sep + "test" + sep + "");
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[0]->subDir == "dir2" + sep);
- REQUIRE(VirtFs::getEntries()[1]->root ==
- prefix + "data" + sep + "test" + sep + "test.zip");
- REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[1]->subDir == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[2]->root ==
- prefix + "data" + sep + "test" + sep + "test2.zip");
- REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[2]->subDir == "dir3" + sep);
- }
-
- SECTION("subDir 6")
- {
- REQUIRE(VirtFs::mountZip2(prefix + "data/test/test.zip",
- dirSeparator,
- Append_false));
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test.zip",
- std::string()) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test2.zip",
- std::string()) == nullptr);
- REQUIRE(VirtFs::getEntries().size() == 1);
- REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data" + sep + "test" + sep + "test.zip");
- REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
- }
-
- VirtFs::deinit();
- delete2(logger);
-}
diff --git a/src/unittests/fs/virtfs/virtfs1_mountzip.cc b/src/unittests/fs/virtfs/virtfs1_mountzip.cc
new file mode 100644
index 000000000..66b1c4e19
--- /dev/null
+++ b/src/unittests/fs/virtfs/virtfs1_mountzip.cc
@@ -0,0 +1,332 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2016-2017 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "unittests/unittests.h"
+
+#include "fs/files.h"
+
+#include "fs/virtfs/direntry.h"
+#include "fs/virtfs/fs.h"
+
+#include "utils/checkutils.h"
+#include "utils/delete2.h"
+
+#ifndef UNITTESTS_CATCH
+#include <algorithm>
+#endif // UNITTESTS_CATCH
+
+#include "debug.h"
+
+TEST_CASE("VirtFs1 mountZip", "")
+{
+ VirtFs::init(".");
+ logger = new Logger();
+ std::string name("data/test/test.zip");
+ std::string prefix;
+ const std::string sep = dirSeparator;
+ if (Files::existsLocal(name) == false)
+ prefix = "../";
+
+ SECTION("simple 1")
+ {
+ REQUIRE(VirtFs::mountZip(prefix + "data/test/test.zip",
+ Append_false));
+ REQUIRE(VirtFs::searchByRootInternal(
+ prefix + "data" + sep + "test" + sep + "test.zip", std::string()) !=
+ nullptr);
+ REQUIRE(VirtFs::searchByRootInternal(
+ prefix + "data" + sep + "test" + sep + "test2.zip",
+ std::string()) == nullptr);
+ REQUIRE(VirtFs::getEntries().size() == 1);
+ REQUIRE(VirtFs::getEntries()[0]->root ==
+ prefix + "data" + sep + "test" + sep + "test.zip");
+ REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
+ REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
+ }
+
+ SECTION("simple 2")
+ {
+ REQUIRE(VirtFs::mountZip(prefix + "data/test/test.zip",
+ Append_false));
+ REQUIRE(VirtFs::mountZip(prefix + "data/test/test2.zip",
+ Append_false));
+ REQUIRE(VirtFs::searchByRootInternal(
+ prefix + "data" + sep + "test" + sep + "test.zip",
+ std::string()) != nullptr);
+ REQUIRE(VirtFs::searchByRootInternal(
+ prefix + "data" + sep + "test" + sep + "test2.zip",
+ std::string()) != nullptr);
+ REQUIRE(VirtFs::getEntries().size() == 2);
+ REQUIRE(VirtFs::getEntries()[0]->root ==
+ prefix + "data" + sep + "test" + sep + "test2.zip");
+ REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
+ REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
+ REQUIRE(VirtFs::getEntries()[1]->root ==
+ prefix + "data" + sep + "test" + sep + "test.zip");
+ REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip);
+ REQUIRE(VirtFs::getEntries()[1]->subDir.empty());
+ }
+
+ SECTION("simple 3")
+ {
+ REQUIRE(VirtFs::mountZip(prefix + "data/test/test.zip",
+ Append_true));
+ REQUIRE(VirtFs::mountZip(prefix + "data/test/test2.zip",
+ Append_true));
+ REQUIRE(VirtFs::searchByRootInternal(
+ prefix + "data" + sep + "test" + sep + "test.zip",
+ std::string()) != nullptr);
+ REQUIRE(VirtFs::searchByRootInternal(
+ prefix + "data" + sep + "test" + sep + "test2.zip",
+ std::string()) != nullptr);
+ REQUIRE(VirtFs::getEntries().size() == 2);
+ REQUIRE(VirtFs::getEntries()[0]->root ==
+ prefix + "data" + sep + "test" + sep + "test.zip");
+ REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
+ REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
+ REQUIRE(VirtFs::getEntries()[1]->root ==
+ prefix + "data" + sep + "test" + sep + "test2.zip");
+ REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip);
+ REQUIRE(VirtFs::getEntries()[1]->subDir.empty());
+ }
+
+ SECTION("simple 4")
+ {
+ REQUIRE(VirtFs::mountZip(prefix + "data/test/test.zip",
+ Append_false));
+ REQUIRE(VirtFs::mountDir(prefix + "data/test",
+ Append_false));
+ REQUIRE(VirtFs::mountZip(prefix + "data/test/test2.zip",
+ Append_false));
+ REQUIRE(VirtFs::searchByRootInternal(
+ prefix + "data" + sep + "test" + sep + "test.zip",
+ std::string()) != nullptr);
+ REQUIRE(VirtFs::searchByRootInternal(
+ prefix + "data" + sep + "test" + sep + "test2.zip",
+ std::string()) != nullptr);
+ REQUIRE(VirtFs::searchByRootInternal(
+ prefix + "data" + sep + "test" + sep + "",
+ std::string()) != nullptr);
+ REQUIRE(VirtFs::getEntries().size() == 3);
+ REQUIRE(VirtFs::getEntries()[0]->root ==
+ prefix + "data" + sep + "test" + sep + "test2.zip");
+ REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
+ REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
+ REQUIRE(VirtFs::getEntries()[1]->root ==
+ prefix + "data" + sep + "test" + sep + "");
+ REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
+ REQUIRE(VirtFs::getEntries()[1]->subDir.empty());
+ REQUIRE(VirtFs::getEntries()[2]->root ==
+ prefix + "data" + sep + "test" + sep + "test.zip");
+ REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Zip);
+ REQUIRE(VirtFs::getEntries()[2]->subDir.empty());
+ }
+
+ SECTION("simple 5")
+ {
+ REQUIRE(VirtFs::mountZip(prefix + "data/test/test.zip",
+ Append_false));
+ REQUIRE(VirtFs::mountDir(prefix + "data/test",
+ Append_false));
+ REQUIRE(VirtFs::mountZip(prefix + "data/test/test2.zip",
+ Append_true));
+ REQUIRE(VirtFs::searchByRootInternal(
+ prefix + "data" + sep + "test" + sep + "test.zip",
+ std::string()) != nullptr);
+ REQUIRE(VirtFs::searchByRootInternal(
+ prefix + "data" + sep + "test" + sep + "test2.zip",
+ std::string()) != nullptr);
+ REQUIRE(VirtFs::searchByRootInternal(
+ prefix + "data" + sep + "test" + sep + "",
+ std::string()) != nullptr);
+ REQUIRE(VirtFs::getEntries().size() == 3);
+ REQUIRE(VirtFs::getEntries()[0]->root ==
+ prefix + "data" + sep + "test" + sep + "");
+ REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
+ REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
+ REQUIRE(VirtFs::getEntries()[1]->root ==
+ prefix + "data" + sep + "test" + sep + "test.zip");
+ REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip);
+ REQUIRE(VirtFs::getEntries()[1]->subDir.empty());
+ REQUIRE(VirtFs::getEntries()[2]->root ==
+ prefix + "data" + sep + "test" + sep + "test2.zip");
+ REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Zip);
+ REQUIRE(VirtFs::getEntries()[2]->subDir.empty());
+ }
+
+ SECTION("subDir 1")
+ {
+ REQUIRE(VirtFs::mountZip2(prefix + "data/test/test.zip",
+ "dir1",
+ Append_false));
+ REQUIRE(VirtFs::searchByRootInternal(
+ prefix + "data" + sep + "test" + sep + "test.zip", "dir1" + sep) !=
+ nullptr);
+ REQUIRE(VirtFs::searchByRootInternal(
+ prefix + "data" + sep + "test" + sep + "test2.zip",
+ std::string()) == nullptr);
+ REQUIRE(VirtFs::getEntries().size() == 1);
+ REQUIRE(VirtFs::getEntries()[0]->root ==
+ prefix + "data" + sep + "test" + sep + "test.zip");
+ REQUIRE(VirtFs::getEntries()[0]->subDir == "dir1" + sep);
+ REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
+ }
+
+ SECTION("subDir 2")
+ {
+ REQUIRE(VirtFs::mountZip2(prefix + "data/test/test.zip",
+ "dir1",
+ Append_false));
+ REQUIRE(VirtFs::mountZip2(prefix + "data/test/test2.zip",
+ "dir2",
+ Append_false));
+ REQUIRE(VirtFs::searchByRootInternal(
+ prefix + "data" + sep + "test" + sep + "test.zip", "dir1" + sep) !=
+ nullptr);
+ REQUIRE(VirtFs::searchByRootInternal(
+ prefix + "data" + sep + "test" + sep + "test2.zip",
+ "dir2" + sep) != nullptr);
+ REQUIRE(VirtFs::getEntries().size() == 2);
+ REQUIRE(VirtFs::getEntries()[0]->root ==
+ prefix + "data" + sep + "test" + sep + "test2.zip");
+ REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
+ REQUIRE(VirtFs::getEntries()[0]->subDir == "dir2" + sep);
+ REQUIRE(VirtFs::getEntries()[1]->root ==
+ prefix + "data" + sep + "test" + sep + "test.zip");
+ REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip);
+ REQUIRE(VirtFs::getEntries()[1]->subDir == "dir1" + sep);
+ }
+
+ SECTION("subDir 3")
+ {
+ REQUIRE(VirtFs::mountZip2(prefix + "data/test/test.zip",
+ "dir1",
+ Append_true));
+ REQUIRE(VirtFs::mountZip2(prefix + "data/test/test2.zip",
+ "dir2",
+ Append_true));
+ REQUIRE(VirtFs::searchByRootInternal(
+ prefix + "data" + sep + "test" + sep + "test.zip",
+ "dir1" + sep) != nullptr);
+ REQUIRE(VirtFs::searchByRootInternal(
+ prefix + "data" + sep + "test" + sep + "test2.zip",
+ "dir2" + sep) != nullptr);
+ REQUIRE(VirtFs::getEntries().size() == 2);
+ REQUIRE(VirtFs::getEntries()[0]->root ==
+ prefix + "data" + sep + "test" + sep + "test.zip");
+ REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
+ REQUIRE(VirtFs::getEntries()[0]->subDir == "dir1" + sep);
+ REQUIRE(VirtFs::getEntries()[1]->root ==
+ prefix + "data" + sep + "test" + sep + "test2.zip");
+ REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip);
+ REQUIRE(VirtFs::getEntries()[1]->subDir == "dir2" + sep);
+ }
+
+ SECTION("subDir 4")
+ {
+ REQUIRE(VirtFs::mountZip2(prefix + "data/test/test.zip",
+ "dir1",
+ Append_false));
+ REQUIRE(VirtFs::mountDir2(prefix + "data/test",
+ "dir2",
+ Append_false));
+ REQUIRE(VirtFs::mountZip2(prefix + "data/test/test2.zip",
+ "dir3",
+ Append_false));
+ REQUIRE(VirtFs::searchByRootInternal(
+ prefix + "data" + sep + "test" + sep + "test.zip",
+ "dir1" + sep) != nullptr);
+ REQUIRE(VirtFs::searchByRootInternal(
+ prefix + "data" + sep + "test" + sep + "test2.zip",
+ "dir3" + sep) != nullptr);
+ REQUIRE(VirtFs::searchByRootInternal(
+ prefix + "data" + sep + "test" + sep + "",
+ "dir2" + sep) != nullptr);
+ REQUIRE(VirtFs::getEntries().size() == 3);
+ REQUIRE(VirtFs::getEntries()[0]->root ==
+ prefix + "data" + sep + "test" + sep + "test2.zip");
+ REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
+ REQUIRE(VirtFs::getEntries()[0]->subDir == "dir3" + sep);
+ REQUIRE(VirtFs::getEntries()[1]->root ==
+ prefix + "data" + sep + "test" + sep + "");
+ REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
+ REQUIRE(VirtFs::getEntries()[1]->subDir == "dir2" + sep);
+ REQUIRE(VirtFs::getEntries()[2]->root ==
+ prefix + "data" + sep + "test" + sep + "test.zip");
+ REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Zip);
+ REQUIRE(VirtFs::getEntries()[2]->subDir == "dir1" + sep);
+ }
+
+ SECTION("subDir 5")
+ {
+ REQUIRE(VirtFs::mountZip2(prefix + "data/test/test.zip",
+ "dir1",
+ Append_false));
+ REQUIRE(VirtFs::mountDir2(prefix + "data/test",
+ "dir2",
+ Append_false));
+ REQUIRE(VirtFs::mountZip2(prefix + "data/test/test2.zip",
+ "dir3",
+ Append_true));
+ REQUIRE(VirtFs::searchByRootInternal(
+ prefix + "data" + sep + "test" + sep + "test.zip",
+ "dir1" + sep) != nullptr);
+ REQUIRE(VirtFs::searchByRootInternal(
+ prefix + "data" + sep + "test" + sep + "test2.zip",
+ "dir3" + sep) != nullptr);
+ REQUIRE(VirtFs::searchByRootInternal(
+ prefix + "data" + sep + "test" + sep + "",
+ "dir2" + sep) != nullptr);
+ REQUIRE(VirtFs::getEntries().size() == 3);
+ REQUIRE(VirtFs::getEntries()[0]->root ==
+ prefix + "data" + sep + "test" + sep + "");
+ REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
+ REQUIRE(VirtFs::getEntries()[0]->subDir == "dir2" + sep);
+ REQUIRE(VirtFs::getEntries()[1]->root ==
+ prefix + "data" + sep + "test" + sep + "test.zip");
+ REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip);
+ REQUIRE(VirtFs::getEntries()[1]->subDir == "dir1" + sep);
+ REQUIRE(VirtFs::getEntries()[2]->root ==
+ prefix + "data" + sep + "test" + sep + "test2.zip");
+ REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Zip);
+ REQUIRE(VirtFs::getEntries()[2]->subDir == "dir3" + sep);
+ }
+
+ SECTION("subDir 6")
+ {
+ REQUIRE(VirtFs::mountZip2(prefix + "data/test/test.zip",
+ dirSeparator,
+ Append_false));
+ REQUIRE(VirtFs::searchByRootInternal(
+ prefix + "data" + sep + "test" + sep + "test.zip",
+ std::string()) != nullptr);
+ REQUIRE(VirtFs::searchByRootInternal(
+ prefix + "data" + sep + "test" + sep + "test2.zip",
+ std::string()) == nullptr);
+ REQUIRE(VirtFs::getEntries().size() == 1);
+ REQUIRE(VirtFs::getEntries()[0]->root ==
+ prefix + "data" + sep + "test" + sep + "test.zip");
+ REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
+ REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
+ }
+
+ VirtFs::deinit();
+ delete2(logger);
+}