diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-05-16 17:50:47 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-05-16 17:50:47 +0300 |
commit | 3cf47056f239f1096590c27c1d401904a54f84fc (patch) | |
tree | 6e2dc17b22f9afb8079698b38d7dd12ed971b9ad /src/fs/virtfs/virtfs1_unittest.cc | |
parent | 5f66478632d388bfae78cbbb938a42eac3956db2 (diff) | |
download | mv-3cf47056f239f1096590c27c1d401904a54f84fc.tar.gz mv-3cf47056f239f1096590c27c1d401904a54f84fc.tar.bz2 mv-3cf47056f239f1096590c27c1d401904a54f84fc.tar.xz mv-3cf47056f239f1096590c27c1d401904a54f84fc.zip |
Add subdir support in VirtFs::loadFile.
Diffstat (limited to 'src/fs/virtfs/virtfs1_unittest.cc')
-rw-r--r-- | src/fs/virtfs/virtfs1_unittest.cc | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/fs/virtfs/virtfs1_unittest.cc b/src/fs/virtfs/virtfs1_unittest.cc index 78787f9d0..4c046b621 100644 --- a/src/fs/virtfs/virtfs1_unittest.cc +++ b/src/fs/virtfs/virtfs1_unittest.cc @@ -2649,6 +2649,72 @@ TEST_CASE("VirtFs1 loadFile2") delete2(logger); } +TEST_CASE("VirtFs1 loadFile3") +{ + 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::mountDir2(prefix + "data", + "test", + Append_false); + + const char *const buffer = VirtFs::loadFile("test.txt", fileSize); + REQUIRE(static_cast<const void*>(buffer) != nullptr); + REQUIRE(fileSize == 23); + REQUIRE(strncmp(buffer, "test line 1\ntest line 2", 23) == 0); + delete [] buffer; + + VirtFs::unmountDir2(prefix + "data", + "test"); + VirtFs::deinit(); + delete2(logger); +} + +TEST_CASE("VirtFs1 loadFile4") +{ + 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::mountZip2(prefix + "data/test/test2.zip", + "dir2", + Append_false); + + SECTION("test 1") + { + const char *restrict buffer = VirtFs::loadFile("test.txt", + fileSize); + REQUIRE(static_cast<const void*>(buffer) != nullptr); + REQUIRE(fileSize == 23); + REQUIRE(strncmp(buffer, "test line 1\ntest line 2", 23) == 0); + delete [] buffer; + } + + SECTION("test 2") + { + const char *restrict buffer = VirtFs::loadFile("test.txt", + fileSize); + REQUIRE(static_cast<const void*>(buffer) != nullptr); + REQUIRE(fileSize == 23); + REQUIRE(strncmp(buffer, "test line 1\ntest line 2", 23) == 0); + delete [] buffer; + } + + VirtFs::unmountZip2(prefix + "data/test/test2.zip", + "dir2"); + VirtFs::deinit(); + delete2(logger); +} + TEST_CASE("VirtFs1 rwops_read1") { VirtFs::init("."); |