diff options
Diffstat (limited to 'Source/kwsys/testSystemTools.cxx')
-rw-r--r-- | Source/kwsys/testSystemTools.cxx | 80 |
1 files changed, 72 insertions, 8 deletions
diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx index c4da9e1..d633b3d 100644 --- a/Source/kwsys/testSystemTools.cxx +++ b/Source/kwsys/testSystemTools.cxx @@ -29,6 +29,8 @@ #include "testSystemTools.h" +#include <string.h> /* strcmp */ + //---------------------------------------------------------------------------- const char* toUnixPaths[][2] = { @@ -93,7 +95,7 @@ bool CheckEscapeChars(kwsys_stl::string input, } //---------------------------------------------------------------------------- -bool CheckDetectFileType() +bool CheckFileOperations() { bool res = true; @@ -114,6 +116,14 @@ bool CheckDetectFileType() << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl; res = false; } + + if (kwsys::SystemTools::FileLength(TEST_SYSTEMTOOLS_BIN_FILE) != 766) + { + kwsys_ios::cerr + << "Problem with FileLength - incorrect length for: " + << TEST_SYSTEMTOOLS_BIN_FILE << kwsys_ios::endl; + res = false; + } return res; } @@ -156,7 +166,6 @@ bool CheckStringOperations() kwsys::SystemTools::AppendStrings("Mary Had A"," Little Lamb."); if (strcmp(cres,"Mary Had A Little Lamb.")) { - delete [] cres; kwsys_ios::cerr << "Problem with AppendStrings " << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl; @@ -168,7 +177,6 @@ bool CheckStringOperations() kwsys::SystemTools::AppendStrings("Mary Had"," A ","Little Lamb."); if (strcmp(cres,"Mary Had A Little Lamb.")) { - delete [] cres; kwsys_ios::cerr << "Problem with AppendStrings " << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl; @@ -188,7 +196,6 @@ bool CheckStringOperations() kwsys::SystemTools::RemoveChars("Mary Had A Little Lamb.","aeiou"); if (strcmp(cres,"Mry Hd A Lttl Lmb.")) { - delete [] cres; kwsys_ios::cerr << "Problem with RemoveChars " << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl; @@ -200,7 +207,6 @@ bool CheckStringOperations() kwsys::SystemTools::RemoveCharsButUpperHex("Mary Had A Little Lamb."); if (strcmp(cres,"A")) { - delete [] cres; kwsys_ios::cerr << "Problem with RemoveCharsButUpperHex " << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl; @@ -213,7 +219,6 @@ bool CheckStringOperations() kwsys::SystemTools::ReplaceChars(cres2,"aeiou",'X'); if (strcmp(cres2,"MXry HXd A LXttlX LXmb.")) { - delete [] cres2; kwsys_ios::cerr << "Problem with ReplaceChars " << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl; @@ -242,7 +247,6 @@ bool CheckStringOperations() cres = kwsys::SystemTools::DuplicateString("Mary Had A Little Lamb."); if (strcmp(cres,"Mary Had A Little Lamb.")) { - delete [] cres; kwsys_ios::cerr << "Problem with DuplicateString " << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl; @@ -259,7 +263,67 @@ bool CheckStringOperations() << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl; res = false; } + + kwsys_stl::vector<kwsys_stl::string> lines; + kwsys::SystemTools::Split("Mary Had A Little Lamb.",lines,' '); + if (lines[0] != "Mary" || lines[1] != "Had" || + lines[2] != "A" || lines[3] != "Little" || lines[4] != "Lamb.") + { + kwsys_ios::cerr + << "Problem with Split " + << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl; + res = false; + } + + if (kwsys::SystemTools::ConvertToWindowsOutputPath + ("L://Local Mojo/Hex Power Pack/Iffy Voodoo") != + "\"L:\\Local Mojo\\Hex Power Pack\\Iffy Voodoo\"") + { + kwsys_ios::cerr + << "Problem with ConvertToWindowsOutputPath " + << kwsys_ios::endl; + res = false; + } + if (kwsys::SystemTools::ConvertToWindowsOutputPath + ("//grayson/Local Mojo/Hex Power Pack/Iffy Voodoo") != + "\"\\\\grayson\\Local Mojo\\Hex Power Pack\\Iffy Voodoo\"") + { + kwsys_ios::cerr + << "Problem with ConvertToWindowsOutputPath " + << kwsys_ios::endl; + res = false; + } + + if (kwsys::SystemTools::ConvertToUnixOutputPath + ("//Local Mojo/Hex Power Pack/Iffy Voodoo") != + "/Local\\ Mojo/Hex\\ Power\\ Pack/Iffy\\ Voodoo") + { + kwsys_ios::cerr + << "Problem with ConvertToUnixOutputPath " + << kwsys_ios::endl; + res = false; + } + + int targc; + char **targv; + kwsys::SystemTools::ConvertWindowsCommandLineToUnixArguments + ("\"Local Mojo\\Voodoo.asp\" -CastHex \"D:\\My Secret Mojo\\Voodoo.mp3\"", &targc, &targv); + if (targc != 4 || strcmp(targv[1],"Local Mojo\\Voodoo.asp") || + strcmp(targv[2],"-CastHex") || + strcmp(targv[3],"D:\\My Secret Mojo\\Voodoo.mp3")) + { + kwsys_ios::cerr + << "Problem with ConvertWindowsCommandLineToUnixArguments" + << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl; + res = false; + } + for (;targc >=0; --targc) + { + delete [] targv[targc]; + } + delete [] targv; + return res; } @@ -288,7 +352,7 @@ int main(/*int argc, char* argv*/) *checkEscapeChars[cc][2], checkEscapeChars[cc][3]); } - res &= CheckDetectFileType(); + res &= CheckFileOperations(); res &= CheckStringOperations(); |