diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-05-15 22:26:37 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-05-15 22:26:37 +0300 |
commit | 85bd82c4f466ab3038928f12517712e94be61598 (patch) | |
tree | a5bb6e9bca03fa5e6c8dae0d042da591a6a8bdbc | |
parent | 430d2aac2aaf86a71375e157b42085656b1fa5ab (diff) | |
download | mv-85bd82c4f466ab3038928f12517712e94be61598.tar.gz mv-85bd82c4f466ab3038928f12517712e94be61598.tar.bz2 mv-85bd82c4f466ab3038928f12517712e94be61598.tar.xz mv-85bd82c4f466ab3038928f12517712e94be61598.zip |
Add tests for mountZip/mountZip2.
-rw-r--r-- | src/fs/virtfs/virtfs1_unittest.cc | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/src/fs/virtfs/virtfs1_unittest.cc b/src/fs/virtfs/virtfs1_unittest.cc index c623f54cb..020064ad0 100644 --- a/src/fs/virtfs/virtfs1_unittest.cc +++ b/src/fs/virtfs/virtfs1_unittest.cc @@ -493,6 +493,7 @@ TEST_CASE("VirtFs1 mountZip") REQUIRE(VirtFs::getEntries().size() == 1); REQUIRE(VirtFs::getEntries()[0]->root == prefix + "data" + sep + "test" + sep + "test.zip"); + REQUIRE(VirtFs::getEntries()[0]->subDir == sep); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip); } @@ -512,9 +513,11 @@ TEST_CASE("VirtFs1 mountZip") REQUIRE(VirtFs::getEntries()[0]->root == prefix + "data" + sep + "test" + sep + "test2.zip"); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip); + REQUIRE(VirtFs::getEntries()[0]->subDir == 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 == sep); } SECTION("simple 3") @@ -533,9 +536,11 @@ TEST_CASE("VirtFs1 mountZip") REQUIRE(VirtFs::getEntries()[0]->root == prefix + "data" + sep + "test" + sep + "test.zip"); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip); + REQUIRE(VirtFs::getEntries()[0]->subDir == 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 == sep); } SECTION("simple 4") @@ -559,12 +564,15 @@ TEST_CASE("VirtFs1 mountZip") REQUIRE(VirtFs::getEntries()[0]->root == prefix + "data" + sep + "test" + sep + "test2.zip"); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip); + REQUIRE(VirtFs::getEntries()[0]->subDir == sep); REQUIRE(VirtFs::getEntries()[1]->root == prefix + "data" + sep + "test" + sep + ""); REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir); + REQUIRE(VirtFs::getEntries()[1]->subDir == 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 == sep); } SECTION("simple 5") @@ -588,12 +596,153 @@ TEST_CASE("VirtFs1 mountZip") REQUIRE(VirtFs::getEntries()[0]->root == prefix + "data" + sep + "test" + sep + ""); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir); + REQUIRE(VirtFs::getEntries()[0]->subDir == 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 == 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 == sep); + } + + 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") != + nullptr); + REQUIRE(VirtFs::searchByRootInternal( + prefix + "data" + sep + "test" + sep + "test2.zip", dirSeparator) == + nullptr); + REQUIRE(VirtFs::getEntries().size() == 1); + REQUIRE(VirtFs::getEntries()[0]->root == + prefix + "data" + sep + "test" + sep + "test.zip"); + REQUIRE(VirtFs::getEntries()[0]->subDir == "dir1"); + 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") != + nullptr); + REQUIRE(VirtFs::searchByRootInternal( + prefix + "data" + sep + "test" + sep + "test2.zip", + "dir2") != 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"); 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"); + } + + 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") != nullptr); + REQUIRE(VirtFs::searchByRootInternal( + prefix + "data" + sep + "test" + sep + "test2.zip", + "dir2") != 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"); + 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"); + } + + 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") != nullptr); + REQUIRE(VirtFs::searchByRootInternal( + prefix + "data" + sep + "test" + sep + "test2.zip", + "dir3") != nullptr); + REQUIRE(VirtFs::searchByRootInternal( + prefix + "data" + sep + "test" + sep + "", + "dir2") != 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"); + REQUIRE(VirtFs::getEntries()[1]->root == + prefix + "data" + sep + "test" + sep + ""); + REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir); + REQUIRE(VirtFs::getEntries()[1]->subDir == "dir2"); + 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"); + } + + 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") != nullptr); + REQUIRE(VirtFs::searchByRootInternal( + prefix + "data" + sep + "test" + sep + "test2.zip", + "dir3") != nullptr); + REQUIRE(VirtFs::searchByRootInternal( + prefix + "data" + sep + "test" + sep + "", + "dir2") != 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"); + 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"); 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"); } VirtFs::deinit(); |