diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2005-04-13 17:57:24 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2005-04-13 17:57:24 (GMT) |
commit | 4a390c174cb4e96963b0f1392828f1f1da70c61f (patch) | |
tree | 43f038f99605da1ef3221b61cee70d0f6dec35db /Source/kwsys/testSystemTools.cxx | |
parent | 3778d89cb907b9283c86a0e74be8dd4b9118ba5e (diff) | |
download | CMake-4a390c174cb4e96963b0f1392828f1f1da70c61f.zip CMake-4a390c174cb4e96963b0f1392828f1f1da70c61f.tar.gz CMake-4a390c174cb4e96963b0f1392828f1f1da70c61f.tar.bz2 |
ENH: Do kwsys testing as part of cmake testing, command line arguments are not experimental and add simple test for systemtools
Diffstat (limited to 'Source/kwsys/testSystemTools.cxx')
-rw-r--r-- | Source/kwsys/testSystemTools.cxx | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx new file mode 100644 index 0000000..28de9a9 --- /dev/null +++ b/Source/kwsys/testSystemTools.cxx @@ -0,0 +1,64 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile$ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "kwsysPrivate.h" +#include KWSYS_HEADER(SystemTools.hxx) +#include KWSYS_HEADER(ios/iostream) + +const char* toUnixPaths[][2] = +{ + { "/usr/local/bin/passwd", "/usr/local/bin/passwd" }, + { "/usr/lo cal/bin/pa sswd", "/usr/lo cal/bin/pa sswd" }, + { "/usr/lo\\ cal/bin/pa\\ sswd", "/usr/lo\\ cal/bin/pa\\ sswd" }, + { "c:/usr/local/bin/passwd", "c:/usr/local/bin/passwd" }, + { "c:/usr/lo cal/bin/pa sswd", "c:/usr/lo cal/bin/pa sswd" }, + { "c:/usr/lo\\ cal/bin/pa\\ sswd", "c:/usr/lo\\ cal/bin/pa\\ sswd" }, + { "\\usr\\local\\bin\\passwd", "/usr/local/bin/passwd" }, + { "\\usr\\lo cal\\bin\\pa sswd", "/usr/lo cal/bin/pa sswd" }, + { "\\usr\\lo\\ cal\\bin\\pa\\ sswd", "/usr/lo\\ cal/bin/pa\\ sswd" }, + { "c:\\usr\\local\\bin\\passwd", "c:/usr/local/bin/passwd" }, + { "c:\\usr\\lo cal\\bin\\pa sswd", "c:/usr/lo cal/bin/pa sswd" }, + { "c:\\usr\\lo\\ cal\\bin\\pa\\ sswd", "c:/usr/lo\\ cal/bin/pa\\ sswd" }, + { "\\\\usr\\local\\bin\\passwd", "//usr/local/bin/passwd" }, + { "\\\\usr\\lo cal\\bin\\pa sswd", "//usr/lo cal/bin/pa sswd" }, + { "\\\\usr\\lo\\ cal\\bin\\pa\\ sswd", "//usr/lo\\ cal/bin/pa\\ sswd" }, + {0, 0} +}; + +bool CheckConvertToUnixSlashes(kwsys_stl::string input, kwsys_stl::string output) +{ + kwsys_stl::string result = input; + kwsys::SystemTools::ConvertToUnixSlashes(result); + if ( result != output ) + { + kwsys_ios::cerr << "Problem with ConvertToUnixSlashes - input: " << input.c_str() << " output: " << result.c_str() << " expected: " << output.c_str() << kwsys_ios::endl; + return false; + } + return true; +} + +int main(/*int argc, char* argv*/) +{ + int cc; + for ( cc = 0; toUnixPaths[cc][0]; cc ++ ) + { + CheckConvertToUnixSlashes(toUnixPaths[cc][0], toUnixPaths[cc][1]); + } + { + // Special check for ~ + kwsys_stl::string output = kwsys::SystemTools::GetEnv("HOME"); + output += "/foo bar/lala"; + CheckConvertToUnixSlashes("~/foo bar/lala", output); + } + return 0; +} |