summaryrefslogtreecommitdiffstats
path: root/testSystemTools.cxx
diff options
context:
space:
mode:
authorKWSys Upstream <kwrobot@kitware.com>2017-12-12 12:08:43 (GMT)
committerBrad King <brad.king@kitware.com>2017-12-12 12:51:50 (GMT)
commitc6a83ecf1761eea8d0907ea9d8913fe56029a00d (patch)
tree43dbc1381be56133e776463fae2462d91988c6c7 /testSystemTools.cxx
parent3b1bb703a2f75f26fd453e50f848b5dbd64bc169 (diff)
downloadCMake-c6a83ecf1761eea8d0907ea9d8913fe56029a00d.zip
CMake-c6a83ecf1761eea8d0907ea9d8913fe56029a00d.tar.gz
CMake-c6a83ecf1761eea8d0907ea9d8913fe56029a00d.tar.bz2
KWSys 2017-12-12 (3ba214b7)
Code extracted from: https://gitlab.kitware.com/utils/kwsys.git at commit 3ba214b7963fdd59f6f230c100550f9c5aa3deab (master). Upstream Shortlog ----------------- Gregor Jasny (1): 8e029751 SystemTools: Fix IsSubDirectory for subdirs of drive root
Diffstat (limited to 'testSystemTools.cxx')
-rw-r--r--testSystemTools.cxx35
1 files changed, 35 insertions, 0 deletions
diff --git a/testSystemTools.cxx b/testSystemTools.cxx
index 3b694c9..a6af9cc 100644
--- a/testSystemTools.cxx
+++ b/testSystemTools.cxx
@@ -813,6 +813,39 @@ static bool CheckFind()
return res;
}
+static bool CheckIsSubDirectory()
+{
+ bool res = true;
+
+ if (kwsys::SystemTools::IsSubDirectory("/foo", "/") == false) {
+ std::cerr << "Problem with IsSubDirectory (root - unix): " << std::endl;
+ res = false;
+ }
+ if (kwsys::SystemTools::IsSubDirectory("c:/foo", "c:/") == false) {
+ std::cerr << "Problem with IsSubDirectory (root - dos): " << std::endl;
+ res = false;
+ }
+ if (kwsys::SystemTools::IsSubDirectory("/foo/bar", "/foo") == false) {
+ std::cerr << "Problem with IsSubDirectory (deep): " << std::endl;
+ res = false;
+ }
+ if (kwsys::SystemTools::IsSubDirectory("/foo", "/foo") == true) {
+ std::cerr << "Problem with IsSubDirectory (identity): " << std::endl;
+ res = false;
+ }
+ if (kwsys::SystemTools::IsSubDirectory("/fooo", "/foo") == true) {
+ std::cerr << "Problem with IsSubDirectory (substring): " << std::endl;
+ res = false;
+ }
+ if (kwsys::SystemTools::IsSubDirectory("/foo/", "/foo") == true) {
+ std::cerr << "Problem with IsSubDirectory (prepended slash): "
+ << std::endl;
+ res = false;
+ }
+
+ return res;
+}
+
static bool CheckGetLineFromStream()
{
const std::string fileWithFiveCharsOnFirstLine(TEST_SYSTEMTOOLS_SOURCE_DIR
@@ -897,6 +930,8 @@ int testSystemTools(int, char* [])
res &= CheckFind();
+ res &= CheckIsSubDirectory();
+
res &= CheckGetLineFromStream();
res &= CheckGetFilenameName();