summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-02-15 15:56:45 +0300
committerAndrei Karas <akaras@inbox.ru>2017-02-15 17:12:19 +0300
commitd6bf14eebdfb9939e0fa1f61f81fa1046ff9ea27 (patch)
treea48d3d2cf16e347e18a65020d755371eb0cabcfe
parent42b05f92d4466aa49806ab7d1e6985ad943ae1ea (diff)
downloadmanaplus-d6bf14eebdfb9939e0fa1f61f81fa1046ff9ea27.tar.gz
manaplus-d6bf14eebdfb9939e0fa1f61f81fa1046ff9ea27.tar.bz2
manaplus-d6bf14eebdfb9939e0fa1f61f81fa1046ff9ea27.tar.xz
manaplus-d6bf14eebdfb9939e0fa1f61f81fa1046ff9ea27.zip
Fix unit tests if unpack from tarball. Here soft links replaced to actual files.
-rw-r--r--src/utils/virtfs.cpp5
-rw-r--r--src/utils/virtfs.h1
-rw-r--r--src/utils/virtfs_unittest.cc24
3 files changed, 18 insertions, 12 deletions
diff --git a/src/utils/virtfs.cpp b/src/utils/virtfs.cpp
index 7c67deebc..fdcdab6d6 100644
--- a/src/utils/virtfs.cpp
+++ b/src/utils/virtfs.cpp
@@ -106,6 +106,11 @@ namespace VirtFs
return PHYSFS_isDirectory(name.c_str());
}
+ bool isSymbolicLink(const std::string &restrict name)
+ {
+ return PHYSFS_isSymbolicLink(name.c_str());
+ }
+
void freeList(VirtList *restrict const handle)
{
delete handle;
diff --git a/src/utils/virtfs.h b/src/utils/virtfs.h
index 2b2550826..e0f188cfb 100644
--- a/src/utils/virtfs.h
+++ b/src/utils/virtfs.h
@@ -40,6 +40,7 @@ namespace VirtFs
bool exists(const std::string &restrict name);
VirtList *enumerateFiles(const std::string &restrict dir) RETURNS_NONNULL;
bool isDirectory(const std::string &restrict name);
+ bool isSymbolicLink(const std::string &restrict name);
void freeList(VirtList *restrict const handle);
VirtFile *openRead(const std::string &restrict filename);
VirtFile *openWrite(const std::string &restrict filename);
diff --git a/src/utils/virtfs_unittest.cc b/src/utils/virtfs_unittest.cc
index b35d31215..af2c22dee 100644
--- a/src/utils/virtfs_unittest.cc
+++ b/src/utils/virtfs_unittest.cc
@@ -110,26 +110,26 @@ TEST_CASE("VirtFs enumerateFiles")
VirtList *list = nullptr;
+ const int cnt1 = VirtFs::exists("test/test2.txt") ? 23 : 22;
+ const int cnt2 = 23;
+
VirtFs::permitLinks(false);
list = VirtFs::enumerateFiles("test");
removeTemp(list->names);
const size_t sz = list->names.size();
- REQUIRE(sz == 22);
+ REQUIRE(sz == cnt1);
VirtFs::freeList(list);
VirtFs::permitLinks(true);
list = VirtFs::enumerateFiles("test");
removeTemp(list->names);
- REQUIRE(list->names.size() > sz);
- REQUIRE(list->names.size() - sz == 1);
- REQUIRE(list->names.size() == 23);
+ REQUIRE(list->names.size() == cnt2);
VirtFs::freeList(list);
VirtFs::permitLinks(false);
list = VirtFs::enumerateFiles("test");
removeTemp(list->names);
- REQUIRE(list->names.size() == sz);
- REQUIRE(list->names.size() == 22);
+ REQUIRE(list->names.size() == cnt1);
VirtFs::freeList(list);
VirtFs::removeDirFromSearchPath("data");
@@ -331,27 +331,27 @@ TEST_CASE("VirtFs permitLinks")
VirtFs::addDirToSearchPath("data", Append_false);
VirtFs::addDirToSearchPath("../data", Append_false);
+ const int cnt1 = VirtFs::exists("test/test2.txt") ? 22 : 21;
+ const int cnt2 = 22;
+
StringVect list;
VirtFs::permitLinks(false);
VirtFs::getFiles("test", list);
removeTemp(list);
const size_t sz = list.size();
- REQUIRE(sz == 21);
+ REQUIRE(sz == cnt1);
list.clear();
VirtFs::permitLinks(true);
VirtFs::getFiles("test", list);
removeTemp(list);
- REQUIRE(list.size() > sz);
- REQUIRE(list.size() - sz == 1);
- REQUIRE(list.size() == 22);
+ REQUIRE(list.size() == cnt2);
list.clear();
VirtFs::permitLinks(false);
VirtFs::getFiles("test", list);
removeTemp(list);
- REQUIRE(list.size() == sz);
- REQUIRE(list.size() == 21);
+ REQUIRE(list.size() == cnt1);
VirtFs::removeDirFromSearchPath("data");
VirtFs::removeDirFromSearchPath("../data");