diff options
author | Brad King <brad.king@kitware.com> | 2017-12-12 12:51:51 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-12-12 12:51:51 (GMT) |
commit | 834d1878415fddb04b388b042dba7ce55a9a8a5d (patch) | |
tree | 0290041fcec80a69e59cda5f556f2b3e143b0c29 /Source/kwsys/testSystemTools.cxx | |
parent | 62d8bff146b28c10c11ad7ef8114f8d06f2fcad8 (diff) | |
parent | c6a83ecf1761eea8d0907ea9d8913fe56029a00d (diff) | |
download | CMake-834d1878415fddb04b388b042dba7ce55a9a8a5d.zip CMake-834d1878415fddb04b388b042dba7ce55a9a8a5d.tar.gz CMake-834d1878415fddb04b388b042dba7ce55a9a8a5d.tar.bz2 |
Merge branch 'upstream-KWSys' into update-kwsys
* upstream-KWSys:
KWSys 2017-12-12 (3ba214b7)
Diffstat (limited to 'Source/kwsys/testSystemTools.cxx')
-rw-r--r-- | Source/kwsys/testSystemTools.cxx | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx index 3b694c9..a6af9cc 100644 --- a/Source/kwsys/testSystemTools.cxx +++ b/Source/kwsys/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(); |