summaryrefslogtreecommitdiff
path: root/src/fs/virtfs/virtfs1_unittest.cc
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-05-16 02:41:29 +0300
committerAndrei Karas <akaras@inbox.ru>2017-05-16 02:41:29 +0300
commitcfb75b015a4e70843e571ce599e11bf2990abc1b (patch)
tree6ad173a6e0343364fc5ee747171f652b49ff4cce /src/fs/virtfs/virtfs1_unittest.cc
parent24bd6a6d26bab89126db7183bb693779a1742c6d (diff)
downloadplus-cfb75b015a4e70843e571ce599e11bf2990abc1b.tar.gz
plus-cfb75b015a4e70843e571ce599e11bf2990abc1b.tar.bz2
plus-cfb75b015a4e70843e571ce599e11bf2990abc1b.tar.xz
plus-cfb75b015a4e70843e571ce599e11bf2990abc1b.zip
Add subdir support into VirtFs::getRealDir.
Diffstat (limited to 'src/fs/virtfs/virtfs1_unittest.cc')
-rw-r--r--src/fs/virtfs/virtfs1_unittest.cc50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/fs/virtfs/virtfs1_unittest.cc b/src/fs/virtfs/virtfs1_unittest.cc
index d34af34aa..264f92079 100644
--- a/src/fs/virtfs/virtfs1_unittest.cc
+++ b/src/fs/virtfs/virtfs1_unittest.cc
@@ -1404,6 +1404,56 @@ TEST_CASE("VirtFs1 getRealDir2")
delete2(logger);
}
+TEST_CASE("VirtFs1 getRealDir3")
+{
+ VirtFs::init(".");
+ logger = new Logger();
+ const std::string sep = dirSeparator;
+ REQUIRE(VirtFs::getRealDir(".") == "");
+ REQUIRE(VirtFs::getRealDir("..") == "");
+ const bool dir1 = VirtFs::mountDirSilent2("data",
+ "test",
+ Append_false);
+ REQUIRE((dir1 || VirtFs::mountDirSilent2("../data",
+ "test",
+ Append_false)) == true);
+ REQUIRE(VirtFs::getRealDir("file1.txt") == "");
+ if (dir1 == true)
+ {
+ REQUIRE(VirtFs::getRealDir("dir1") == "data");
+ REQUIRE(VirtFs::getRealDir("simplefile.txt") == "data");
+ }
+ else
+ {
+ REQUIRE(VirtFs::getRealDir("dir1") == ".." + sep + "data");
+ REQUIRE(VirtFs::getRealDir("simplefile.txt") == ".." + sep + "data");
+ }
+ REQUIRE(VirtFs::getRealDir("zzz") == "");
+
+ VirtFs::mountDirSilent2("data/test",
+ "dir2",
+ Append_false);
+ VirtFs::mountDirSilent2("../data/test",
+ "dir2",
+ Append_false);
+ REQUIRE(VirtFs::getRealDir("dir") == "");
+ if (dir1 == true)
+ {
+ REQUIRE(VirtFs::getRealDir("file1.txt") == "data");
+ REQUIRE(VirtFs::getRealDir("simplefile.txt") == "data" + sep + "test");
+ }
+ else
+ {
+ REQUIRE(VirtFs::getRealDir("file1.txt") ==
+ ".." + sep + "data" + sep + "test");
+ REQUIRE(VirtFs::getRealDir("simplefile.txt") == ".." + sep + "data");
+ }
+ REQUIRE(VirtFs::getRealDir("zzz") == "");
+
+ VirtFs::deinit();
+ delete2(logger);
+}
+
static bool inList(const VirtFs::List *const list,
const std::string &name)
{