summaryrefslogtreecommitdiffstats
path: root/testSystemTools.cxx
diff options
context:
space:
mode:
authorKWSys Robot <kwrobot@kitware.com>2015-09-28 13:29:33 (GMT)
committerBrad King <brad.king@kitware.com>2015-09-29 14:09:57 (GMT)
commitcc144ebfd8b3a7b89e07c3b22b6a9e8540e5d0e2 (patch)
treeccdf9307dde9f8a96141fcc16f629be605899a50 /testSystemTools.cxx
parent29ad06947244d1a0f04deaf5360e2f1d1765d903 (diff)
downloadCMake-cc144ebfd8b3a7b89e07c3b22b6a9e8540e5d0e2.zip
CMake-cc144ebfd8b3a7b89e07c3b22b6a9e8540e5d0e2.tar.gz
CMake-cc144ebfd8b3a7b89e07c3b22b6a9e8540e5d0e2.tar.bz2
KWSys 2015-09-28 (2089567a)
Extract upstream KWSys using the following shell commands. $ git archive --prefix=upstream-kwsys/ 2089567a | tar x $ git shortlog --no-merges --abbrev=8 --format='%h %s' dc4e4a55..2089567a Vitaly Baranov (1): 2089567a SystemTools: Fix GetPath to not affect existing output vector entries
Diffstat (limited to 'testSystemTools.cxx')
-rw-r--r--testSystemTools.cxx63
1 files changed, 63 insertions, 0 deletions
diff --git a/testSystemTools.cxx b/testSystemTools.cxx
index e14d2fc..a0f904f 100644
--- a/testSystemTools.cxx
+++ b/testSystemTools.cxx
@@ -28,6 +28,7 @@
#include <testSystemTools.h>
#include <iostream>
+#include <sstream>
#include <string.h> /* strcmp */
#if defined(_WIN32) && !defined(__CYGWIN__)
# include <io.h> /* _umask (MSVC) / umask (Borland) */
@@ -790,6 +791,66 @@ static bool CheckCollapsePath()
return res;
}
+static std::string StringVectorToString(const std::vector<std::string>& vec)
+{
+ std::stringstream ss;
+ ss << "vector(";
+ for (std::vector<std::string>::const_iterator i = vec.begin();
+ i != vec.end(); ++i)
+ {
+ if (i != vec.begin())
+ {
+ ss << ", ";
+ }
+ ss << *i;
+ }
+ ss << ")";
+ return ss.str();
+}
+
+static bool CheckGetPath()
+{
+ const char* envName = "S";
+#ifdef _WIN32
+ const char* envValue = "C:\\Somewhere\\something;D:\\Temp";
+#else
+ const char* envValue = "/Somewhere/something:/tmp";
+#endif
+ const char* registryPath = "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MyApp; MyKey]";
+
+ std::vector<std::string> originalPathes;
+ originalPathes.push_back(registryPath);
+
+ std::vector<std::string> expectedPathes;
+ expectedPathes.push_back(registryPath);
+#ifdef _WIN32
+ expectedPathes.push_back("C:/Somewhere/something");
+ expectedPathes.push_back("D:/Temp");
+#else
+ expectedPathes.push_back("/Somewhere/something");
+ expectedPathes.push_back("/tmp");
+#endif
+
+ bool res = true;
+ res &= CheckPutEnv(std::string(envName) + "=" + envValue, envName, envValue);
+
+ std::vector<std::string> pathes = originalPathes;
+ kwsys::SystemTools::GetPath(pathes, envName);
+
+ if (pathes != expectedPathes)
+ {
+ std::cerr <<
+ "GetPath(" << StringVectorToString(originalPathes) <<
+ ", " << envName << ") yielded " << StringVectorToString(pathes) <<
+ " instead of " << StringVectorToString(expectedPathes) <<
+ std::endl;
+ res = false;
+ }
+
+ res &= CheckUnPutEnv(envName, envName);
+ return res;
+}
+
//----------------------------------------------------------------------------
int testSystemTools(int, char*[])
{
@@ -825,5 +886,7 @@ int testSystemTools(int, char*[])
res &= CheckCollapsePath();
+ res &= CheckGetPath();
+
return res ? 0 : 1;
}