summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/fs/virtfs/virtfs1_unittest.cc60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/fs/virtfs/virtfs1_unittest.cc b/src/fs/virtfs/virtfs1_unittest.cc
index 902620303..ee8e97e3e 100644
--- a/src/fs/virtfs/virtfs1_unittest.cc
+++ b/src/fs/virtfs/virtfs1_unittest.cc
@@ -1419,3 +1419,63 @@ TEST_CASE("VirtFs1 read2")
VirtFs::deinit();
delete2(logger);
}
+
+TEST_CASE("VirtFs1 loadFile1")
+{
+ VirtFs::init(".");
+ int fileSize = 0;
+ logger = new Logger();
+ std::string name("data/test/test.zip");
+ std::string prefix;
+ if (Files::existsLocal(name) == false)
+ prefix = "../" + prefix;
+
+ VirtFs::mountDir(prefix + "data",
+ Append_false);
+
+ char *const buffer = VirtFs::loadFile("test/test.txt", fileSize);
+ REQUIRE(static_cast<void*>(buffer) != nullptr);
+ REQUIRE(fileSize == 23);
+ REQUIRE(strncmp(buffer, "test line 1\ntest line 2", 23) == 0);
+ delete [] buffer;
+
+ VirtFs::unmountDir(prefix + "data");
+ VirtFs::deinit();
+ delete2(logger);
+}
+
+TEST_CASE("VirtFs1 loadFile2")
+{
+ VirtFs::init(".");
+ int fileSize = 0;
+ 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);
+
+ SECTION("test 1")
+ {
+ char *restrict buffer = VirtFs::loadFile("dir2//test.txt", fileSize);
+ REQUIRE(static_cast<void*>(buffer) != nullptr);
+ REQUIRE(fileSize == 23);
+ REQUIRE(strncmp(buffer, "test line 1\ntest line 2", 23) == 0);
+ delete [] buffer;
+ }
+
+ SECTION("test 2")
+ {
+ char *restrict buffer = VirtFs::loadFile("dir2\\/test.txt", fileSize);
+ REQUIRE(static_cast<void*>(buffer) != nullptr);
+ REQUIRE(fileSize == 23);
+ REQUIRE(strncmp(buffer, "test line 1\ntest line 2", 23) == 0);
+ delete [] buffer;
+ }
+
+ VirtFs::unmountZip(prefix + "data/test/test2.zip");
+ VirtFs::deinit();
+ delete2(logger);
+}